@best-shot/preset-style 0.12.5 → 0.12.7

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.
@@ -1,24 +1,9 @@
1
1
  import extToRegexp from 'ext-to-regexp';
2
2
  import slashToRegexp from 'slash-to-regexp';
3
3
 
4
- function applyOneOf({ auto = false, mode }) {
5
- return (rule) => {
6
- rule
7
- .use('css-loader')
8
- .loader('css-loader')
9
- .options({
10
- importLoaders: 3,
11
- modules: {
12
- ...(auto ? { auto } : undefined),
13
- exportLocalsConvention: 'camel-case-only',
14
- localIdentName: {
15
- development: '[name]_[local]-[hash]',
16
- production: '[local]-[hash]',
17
- }[mode],
18
- },
19
- });
20
- };
21
- }
4
+ const auto = (resourcePath, resourceQuery) =>
5
+ /\.module\.\w+$/i.test(resourcePath) ||
6
+ new URLSearchParams(resourceQuery).get('module');
22
7
 
23
8
  export async function applyStylesheet(chain) {
24
9
  const minimize = chain.optimization.get('minimize');
@@ -48,24 +33,6 @@ export async function applyStylesheet(chain) {
48
33
  const watch = chain.get('watch');
49
34
  const hot = chain.devServer.get('hot') || false;
50
35
 
51
- chain.module
52
- .rule('style')
53
- .rule('all')
54
- .oneOf('url')
55
- .dependency('url')
56
- .generator.filename('[contenthash].css');
57
-
58
- const parent = chain.module.rule('style').rule('all').oneOf('not-url');
59
-
60
- parent
61
- .oneOf('css-modules-by-query')
62
- .resourceQuery(/module/)
63
- .batch(applyOneOf({ mode }));
64
-
65
- parent
66
- .oneOf('css-modules-by-filename')
67
- .batch(applyOneOf({ mode, auto: true }));
68
-
69
36
  chain.module
70
37
  .rule('style')
71
38
  .rule('postcss')
@@ -77,6 +44,15 @@ export async function applyStylesheet(chain) {
77
44
  },
78
45
  });
79
46
 
47
+ chain.module
48
+ .rule('style')
49
+ .rule('all')
50
+ .oneOf('url')
51
+ .dependency('url')
52
+ .generator.filename('[contenthash].css');
53
+
54
+ const parent = chain.module.rule('style').rule('all').oneOf('not-url');
55
+
80
56
  if (hot) {
81
57
  parent.use('style-loader').loader('style-loader');
82
58
  } else {
@@ -108,4 +84,19 @@ export async function applyStylesheet(chain) {
108
84
  .exclude.add(slashToRegexp('/node_modules/mini-css-extract-plugin/'));
109
85
  }
110
86
  }
87
+
88
+ parent
89
+ .use('css-loader')
90
+ .loader('css-loader')
91
+ .options({
92
+ importLoaders: 3,
93
+ modules: {
94
+ auto,
95
+ exportLocalsConvention: 'camel-case-only',
96
+ localIdentName: {
97
+ development: '[name]_[local]-[hash]',
98
+ production: '[local]-[hash]',
99
+ }[mode],
100
+ },
101
+ });
111
102
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@best-shot/preset-style",
3
- "version": "0.12.5",
3
+ "version": "0.12.7",
4
4
  "description": "A `best-shot` preset for stylesheet",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -52,10 +52,10 @@
52
52
  "style-loader": "^4.0.0"
53
53
  },
54
54
  "peerDependencies": {
55
- "@best-shot/core": "^0.9.6"
55
+ "@best-shot/core": "^0.9.8"
56
56
  },
57
57
  "engines": {
58
- "node": "^18.12.0 || ^20.0.0"
58
+ "node": ">=20.0.0 || ^18.12.0"
59
59
  },
60
60
  "publishConfig": {
61
61
  "access": "public",