@best-shot/preset-style 0.9.0 → 0.9.3
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.
- package/README.md +4 -1
- package/index.mjs +2 -2
- package/lib/apply-stylesheet.mjs +30 -23
- package/package.json +15 -15
package/README.md
CHANGED
|
@@ -15,15 +15,18 @@ A `best-shot` preset for stylesheet.
|
|
|
15
15
|
This preset offer the following features:
|
|
16
16
|
|
|
17
17
|
- [CSS Modules] support
|
|
18
|
+
- [Interoperable CSS] support
|
|
18
19
|
- [Less] / [Sass] syntax support
|
|
19
20
|
- [PostCSS] support
|
|
20
|
-
- Use [postcss-preset-evergreen] by default
|
|
21
|
+
- Use [postcss-preset-evergreen] by default(including [Autoprefixer])
|
|
21
22
|
- Use [cssnano] in production mode
|
|
22
23
|
|
|
24
|
+
[interoperable css]: https://github.com/css-modules/icss
|
|
23
25
|
[css modules]: https://github.com/css-modules/css-modules
|
|
24
26
|
[cssnano]: https://cssnano.co/
|
|
25
27
|
[sass]: https://sass-lang.com/
|
|
26
28
|
[less]: http://lesscss.org/
|
|
29
|
+
[autoprefixer]: https://github.com/postcss/autoprefixer
|
|
27
30
|
[postcss]: https://github.com/postcss/postcss
|
|
28
31
|
[postcss-preset-evergreen]: https://github.com/best-shot/postcss-preset-evergreen
|
|
29
32
|
|
package/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { relative
|
|
1
|
+
import { relative } from 'path';
|
|
2
2
|
import { fileURLToPath } from 'url';
|
|
3
3
|
|
|
4
4
|
import { applyScssLess } from './lib/apply-scss-less.mjs';
|
|
@@ -15,7 +15,7 @@ export function apply({ config: { less } }) {
|
|
|
15
15
|
chain.resolveLoader.modules.prepend(
|
|
16
16
|
relative(
|
|
17
17
|
context,
|
|
18
|
-
|
|
18
|
+
fileURLToPath(new URL('node_modules', import.meta.url)),
|
|
19
19
|
),
|
|
20
20
|
);
|
|
21
21
|
};
|
package/lib/apply-stylesheet.mjs
CHANGED
|
@@ -36,14 +36,26 @@ export async function applyStylesheet(chain) {
|
|
|
36
36
|
]);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
chain.module
|
|
39
|
+
chain.module
|
|
40
|
+
.rule('style')
|
|
41
|
+
.test(extToRegexp({ extname: ['css'] }))
|
|
42
|
+
.oneOf('not-url')
|
|
43
|
+
.set('dependency', { not: 'url' });
|
|
40
44
|
|
|
41
45
|
const mode = chain.get('mode');
|
|
42
46
|
const watch = chain.get('watch');
|
|
47
|
+
const hot = chain.devServer.get('hot') || false;
|
|
43
48
|
|
|
44
|
-
|
|
49
|
+
chain.module
|
|
50
|
+
.rule('style')
|
|
51
|
+
.oneOf('url')
|
|
52
|
+
.set('dependency', 'url')
|
|
53
|
+
.set('generator', {
|
|
54
|
+
filename:
|
|
55
|
+
mode === 'production' ? '[contenthash:8].css' : '[path][name].css',
|
|
56
|
+
});
|
|
45
57
|
|
|
46
|
-
const parent = chain.module.rule('style').rule('css');
|
|
58
|
+
const parent = chain.module.rule('style').oneOf('not-url').rule('css');
|
|
47
59
|
|
|
48
60
|
parent
|
|
49
61
|
.oneOf('css-modules-by-query')
|
|
@@ -65,29 +77,12 @@ export async function applyStylesheet(chain) {
|
|
|
65
77
|
},
|
|
66
78
|
});
|
|
67
79
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
if (!watch && chain.module.rules.has('babel')) {
|
|
71
|
-
chain.module
|
|
72
|
-
.rule('babel')
|
|
73
|
-
.exclude.add(slashToRegexp('/node_modules/css-loader/'));
|
|
74
|
-
|
|
75
|
-
if (extract) {
|
|
76
|
-
chain.module
|
|
77
|
-
.rule('babel')
|
|
78
|
-
.exclude.add(slashToRegexp('/node_modules/mini-css-extract-plugin/'));
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (extract) {
|
|
80
|
+
if (!hot) {
|
|
83
81
|
const { default: MiniCssExtractPlugin } = await import(
|
|
84
82
|
'mini-css-extract-plugin'
|
|
85
83
|
);
|
|
86
84
|
|
|
87
|
-
|
|
88
|
-
.rule('style')
|
|
89
|
-
.use('extract-css')
|
|
90
|
-
.loader(MiniCssExtractPlugin.loader);
|
|
85
|
+
parent.use('extract-css').loader(MiniCssExtractPlugin.loader);
|
|
91
86
|
|
|
92
87
|
chain.plugin('extract-css').use(MiniCssExtractPlugin, [
|
|
93
88
|
{
|
|
@@ -97,6 +92,18 @@ export async function applyStylesheet(chain) {
|
|
|
97
92
|
},
|
|
98
93
|
]);
|
|
99
94
|
} else {
|
|
100
|
-
|
|
95
|
+
parent.use('style-loader').loader('style-loader');
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (!watch && chain.module.rules.has('babel')) {
|
|
99
|
+
chain.module
|
|
100
|
+
.rule('babel')
|
|
101
|
+
.exclude.add(slashToRegexp('/node_modules/css-loader/'));
|
|
102
|
+
|
|
103
|
+
if (!hot) {
|
|
104
|
+
chain.module
|
|
105
|
+
.rule('babel')
|
|
106
|
+
.exclude.add(slashToRegexp('/node_modules/mini-css-extract-plugin/'));
|
|
107
|
+
}
|
|
101
108
|
}
|
|
102
109
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@best-shot/preset-style",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.3",
|
|
4
4
|
"description": "A `best-shot` preset for stylesheet",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -34,27 +34,27 @@
|
|
|
34
34
|
},
|
|
35
35
|
"main": "index.mjs",
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"css-loader": "^6.
|
|
38
|
-
"css-minimizer-webpack-plugin": "^
|
|
39
|
-
"cssnano": "^5.
|
|
37
|
+
"css-loader": "^6.7.1",
|
|
38
|
+
"css-minimizer-webpack-plugin": "^4.0.0",
|
|
39
|
+
"cssnano": "^5.1.12",
|
|
40
40
|
"ext-to-regexp": "^0.1.0",
|
|
41
|
-
"less": "^4.1.
|
|
42
|
-
"less-loader": "^
|
|
43
|
-
"mini-css-extract-plugin": "^2.
|
|
44
|
-
"postcss": "^8.4.
|
|
45
|
-
"postcss-loader": "^
|
|
46
|
-
"postcss-preset-evergreen": "^0.4.
|
|
47
|
-
"resolve-url-loader": "^
|
|
48
|
-
"sass": "^1.
|
|
49
|
-
"sass-loader": "^
|
|
41
|
+
"less": "^4.1.3",
|
|
42
|
+
"less-loader": "^11.0.0",
|
|
43
|
+
"mini-css-extract-plugin": "^2.6.1",
|
|
44
|
+
"postcss": "^8.4.14",
|
|
45
|
+
"postcss-loader": "^7.0.0",
|
|
46
|
+
"postcss-preset-evergreen": "^0.4.5",
|
|
47
|
+
"resolve-url-loader": "^5.0.0",
|
|
48
|
+
"sass": "^1.53.0",
|
|
49
|
+
"sass-loader": "^13.0.2",
|
|
50
50
|
"slash-to-regexp": "^0.0.4",
|
|
51
51
|
"style-loader": "^3.3.1"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"@best-shot/core": "^0.6.
|
|
54
|
+
"@best-shot/core": "^0.6.15"
|
|
55
55
|
},
|
|
56
56
|
"engines": {
|
|
57
|
-
"node": "^14.17.0 ||
|
|
57
|
+
"node": "^14.17.0 || ^16.13.0 || >=18.0.0"
|
|
58
58
|
},
|
|
59
59
|
"publishConfig": {
|
|
60
60
|
"access": "public",
|