@swissquote/crafty-preset-lightningcss 1.22.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/README.md +70 -0
  2. package/dist/webpack-packages/api.js +85 -0
  3. package/dist/webpack-packages/bundled.js +9126 -0
  4. package/dist/webpack-packages/getUrl.js +26 -0
  5. package/dist/webpack-packages/noSourceMaps.js +5 -0
  6. package/dist/webpack-packages/runtime/injectStylesIntoLinkTag.js +29 -0
  7. package/dist/webpack-packages/runtime/injectStylesIntoStyleTag.js +104 -0
  8. package/dist/webpack-packages/runtime/insertBySelector.js +39 -0
  9. package/dist/webpack-packages/runtime/insertStyleElement.js +11 -0
  10. package/dist/webpack-packages/runtime/isEqualLocals.js +35 -0
  11. package/dist/webpack-packages/runtime/isOldIE.js +19 -0
  12. package/dist/webpack-packages/runtime/setAttributesWithAttributes.js +16 -0
  13. package/dist/webpack-packages/runtime/setAttributesWithAttributesAndNonce.js +10 -0
  14. package/dist/webpack-packages/runtime/setAttributesWithoutAttributes.js +12 -0
  15. package/dist/webpack-packages/runtime/singletonStyleDomAPI.js +94 -0
  16. package/dist/webpack-packages/runtime/styleDomAPI.js +70 -0
  17. package/dist/webpack-packages/runtime/styleTagTransform.js +16 -0
  18. package/dist/webpack-packages/sourceMaps.js +16 -0
  19. package/dist/webpack-packages/sourcemap-register.js +1 -0
  20. package/dist/webpack-packages/webpack-packages.js.map +1 -0
  21. package/package.json +30 -0
  22. package/packages/css-loader.js +2 -0
  23. package/packages/lightningcss-loader.js +2 -0
  24. package/packages/style-loader.js +2 -0
  25. package/src/ModuleFilenameHelpers.js +39 -0
  26. package/src/index.js +59 -0
  27. package/src/minify.js +1 -0
  28. package/src/webpack-sources.js +1 -0
  29. package/src/webpack-utils.js +166 -0
package/README.md ADDED
@@ -0,0 +1,70 @@
1
+ <table>
2
+ <tr><th>Compatible Runners</th><td>
3
+
4
+ - [Webpack](05_Packages/02_crafty-runner-webpack.md)
5
+
6
+ </td></tr>
7
+ </table>
8
+
9
+ [TOC]
10
+
11
+ ## Description
12
+
13
+ The principle of CSS is easy to grasp, yet CSS is complicated to write at large scales.
14
+
15
+ We want to offer the best experience for writing CSS that is compatible with most browsers without the long configuration process.
16
+
17
+ ## Features
18
+
19
+ **LightningCSS** is a CSS Processor that will take your CSS, and make it compatible with the largest number of browers. Write tomorrow's CSS today.
20
+
21
+ ## Linting
22
+
23
+ **Stylelint** is a wonderful tool to lint CSS in according to your rules, we have a custom configuration preset for Stylelint that comes pre-configured.
24
+
25
+ Stylelint is provided automatically in this preset by also including [`crafty-preset-stylelint`](05_Packages/05_crafty-preset-stylelint/index.md).
26
+
27
+ ## Installation
28
+
29
+ ```bash
30
+ npm install @swissquote/crafty-preset-lightningcss --save
31
+ ```
32
+
33
+ ```javascript
34
+ module.exports = {
35
+ presets: [
36
+ "@swissquote/crafty-preset-lightningcss",
37
+ "@swissquote/crafty-runner-webpack"
38
+ ]
39
+ };
40
+ ```
41
+
42
+ ## Usage with Webpack
43
+
44
+ Webpack defines the right loaders to support CSS.
45
+
46
+ To use it, add `import "myfile.scss"` in your Webpack imported file.
47
+
48
+ ### Hot Module Replacement
49
+
50
+ When setting `hot: true` in your `crafty.config.js` for your main JavaScript bundle, you can enable Hot Module Replacement.
51
+
52
+ With this, the CSS files imported in your Webpack bundles are automatically reloaded upon changes.
53
+
54
+ This is used inside `crafty watch`, the build mode will not take it into account.
55
+
56
+ ### Extracting CSS
57
+
58
+ By default, the CSS will be embedded in your bundle, but you can provide the `extractCSS` option to extract your styles using the `MiniCssExtractPlugin`.
59
+
60
+ #### Side effects
61
+
62
+ Be careful when using `extractCSS` option and `sideEffects: false` in `package.json` of your project. Crafty is using `css-loader` and when you import a CSS file in your project, it needs to be added to the side effect list so it will not be unintentionally dropped in production mode.
63
+
64
+ [Webpack docs and examples](https://webpack.js.org/guides/tree-shaking/#mark-the-file-as-side-effect-free)
65
+
66
+ ## Bundle Options
67
+
68
+ | Option | Type | Optional ? | Runner | Description |
69
+ | ------------ | ------------------------- | ---------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
70
+ | `extractCSS` | Boolean / String / Object | Yes | Webpack | This will extract the CSS out of the bundle, all [Official options](https://github.com/webpack-contrib/mini-css-extract-plugin#configuration) work, you can also pass `true` which will use `[bundle]-[name].min.css` as file name, you can use `[bundle]` in the file name which is replaced by your bundle name. |
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+
3
+ /*
4
+ MIT License http://www.opensource.org/licenses/mit-license.php
5
+ Author Tobias Koppers @sokra
6
+ */
7
+ module.exports = function (cssWithMappingToString) {
8
+ var list = [];
9
+
10
+ // return the list of modules as css string
11
+ list.toString = function toString() {
12
+ return this.map(function (item) {
13
+ var content = "";
14
+ var needLayer = typeof item[5] !== "undefined";
15
+ if (item[4]) {
16
+ content += "@supports (".concat(item[4], ") {");
17
+ }
18
+ if (item[2]) {
19
+ content += "@media ".concat(item[2], " {");
20
+ }
21
+ if (needLayer) {
22
+ content += "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {");
23
+ }
24
+ content += cssWithMappingToString(item);
25
+ if (needLayer) {
26
+ content += "}";
27
+ }
28
+ if (item[2]) {
29
+ content += "}";
30
+ }
31
+ if (item[4]) {
32
+ content += "}";
33
+ }
34
+ return content;
35
+ }).join("");
36
+ };
37
+
38
+ // import a list of modules into the list
39
+ list.i = function i(modules, media, dedupe, supports, layer) {
40
+ if (typeof modules === "string") {
41
+ modules = [[null, modules, undefined]];
42
+ }
43
+ var alreadyImportedModules = {};
44
+ if (dedupe) {
45
+ for (var k = 0; k < this.length; k++) {
46
+ var id = this[k][0];
47
+ if (id != null) {
48
+ alreadyImportedModules[id] = true;
49
+ }
50
+ }
51
+ }
52
+ for (var _k = 0; _k < modules.length; _k++) {
53
+ var item = [].concat(modules[_k]);
54
+ if (dedupe && alreadyImportedModules[item[0]]) {
55
+ continue;
56
+ }
57
+ if (typeof layer !== "undefined") {
58
+ if (typeof item[5] === "undefined") {
59
+ item[5] = layer;
60
+ } else {
61
+ item[1] = "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {").concat(item[1], "}");
62
+ item[5] = layer;
63
+ }
64
+ }
65
+ if (media) {
66
+ if (!item[2]) {
67
+ item[2] = media;
68
+ } else {
69
+ item[1] = "@media ".concat(item[2], " {").concat(item[1], "}");
70
+ item[2] = media;
71
+ }
72
+ }
73
+ if (supports) {
74
+ if (!item[4]) {
75
+ item[4] = "".concat(supports);
76
+ } else {
77
+ item[1] = "@supports (".concat(item[4], ") {").concat(item[1], "}");
78
+ item[4] = supports;
79
+ }
80
+ }
81
+ list.push(item);
82
+ }
83
+ };
84
+ return list;
85
+ };