@best-shot/preset-style 0.9.2 → 0.9.5

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.
@@ -36,14 +36,28 @@ export async function applyStylesheet(chain) {
36
36
  ]);
37
37
  }
38
38
 
39
- chain.module.rule('style').test(extToRegexp({ extname: ['css'] }));
39
+ chain.module
40
+ .rule('style')
41
+ .test(extToRegexp({ extname: ['css'] }))
42
+ .rule('all')
43
+ .oneOf('not-url')
44
+ .set('dependency', { not: 'url' });
40
45
 
41
46
  const mode = chain.get('mode');
42
47
  const watch = chain.get('watch');
48
+ const hot = chain.devServer.get('hot') || false;
43
49
 
44
- const useHot = chain.devServer.get('hot') || false;
50
+ chain.module
51
+ .rule('style')
52
+ .rule('all')
53
+ .oneOf('url')
54
+ .set('dependency', 'url')
55
+ .set('generator', {
56
+ filename:
57
+ mode === 'production' ? '[contenthash:8].css' : '[path][name].css',
58
+ });
45
59
 
46
- const parent = chain.module.rule('style').rule('css');
60
+ const parent = chain.module.rule('style').rule('all').oneOf('not-url');
47
61
 
48
62
  parent
49
63
  .oneOf('css-modules-by-query')
@@ -65,29 +79,12 @@ export async function applyStylesheet(chain) {
65
79
  },
66
80
  });
67
81
 
68
- const extract = !useHot;
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) {
82
+ if (!hot) {
83
83
  const { default: MiniCssExtractPlugin } = await import(
84
84
  'mini-css-extract-plugin'
85
85
  );
86
86
 
87
- chain.module
88
- .rule('style')
89
- .use('extract-css')
90
- .loader(MiniCssExtractPlugin.loader);
87
+ parent.use('extract-css').loader(MiniCssExtractPlugin.loader);
91
88
 
92
89
  chain.plugin('extract-css').use(MiniCssExtractPlugin, [
93
90
  {
@@ -97,6 +94,18 @@ export async function applyStylesheet(chain) {
97
94
  },
98
95
  ]);
99
96
  } else {
100
- chain.module.rule('style').use('style-loader').loader('style-loader');
97
+ parent.use('style-loader').loader('style-loader');
98
+ }
99
+
100
+ if (!watch && chain.module.rules.has('babel')) {
101
+ chain.module
102
+ .rule('babel')
103
+ .exclude.add(slashToRegexp('/node_modules/css-loader/'));
104
+
105
+ if (!hot) {
106
+ chain.module
107
+ .rule('babel')
108
+ .exclude.add(slashToRegexp('/node_modules/mini-css-extract-plugin/'));
109
+ }
101
110
  }
102
111
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@best-shot/preset-style",
3
- "version": "0.9.2",
3
+ "version": "0.9.5",
4
4
  "description": "A `best-shot` preset for stylesheet",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -36,22 +36,22 @@
36
36
  "dependencies": {
37
37
  "css-loader": "^6.7.1",
38
38
  "css-minimizer-webpack-plugin": "^4.0.0",
39
- "cssnano": "^5.1.9",
39
+ "cssnano": "^5.1.13",
40
40
  "ext-to-regexp": "^0.1.0",
41
- "less": "^4.1.2",
41
+ "less": "^4.1.3",
42
42
  "less-loader": "^11.0.0",
43
- "mini-css-extract-plugin": "^2.6.0",
44
- "postcss": "^8.4.14",
45
- "postcss-loader": "^7.0.0",
46
- "postcss-preset-evergreen": "^0.4.4",
43
+ "mini-css-extract-plugin": "^2.6.1",
44
+ "postcss": "^8.4.16",
45
+ "postcss-loader": "^7.0.1",
46
+ "postcss-preset-evergreen": "^0.4.5",
47
47
  "resolve-url-loader": "^5.0.0",
48
- "sass": "^1.52.1",
49
- "sass-loader": "^13.0.0",
48
+ "sass": "^1.54.4",
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.14"
54
+ "@best-shot/core": "^0.6.19"
55
55
  },
56
56
  "engines": {
57
57
  "node": "^14.17.0 || ^16.13.0 || >=18.0.0"