@best-shot/preset-mini 0.11.25 → 0.11.26

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 (3) hide show
  1. package/index.mjs +2 -14
  2. package/loader.mjs +31 -27
  3. package/package.json +4 -4
package/index.mjs CHANGED
@@ -14,6 +14,7 @@ export function apply({
14
14
  .publicPath('/')
15
15
  .iife(false)
16
16
  .filename('[name].js')
17
+ .cssFilename('[name].wxss')
17
18
  .globalObject('global')
18
19
  .strictModuleErrorHandling(false)
19
20
  .importFunctionName('require.async')
@@ -67,17 +68,6 @@ export function apply({
67
68
  ]);
68
69
  }
69
70
 
70
- chain.module
71
- .rule('style')
72
- .rule('all')
73
- .oneOf('not-url')
74
- .use('css-loader')
75
- .tap((options) => ({
76
- ...options,
77
- import: false,
78
- modules: false,
79
- }));
80
-
81
71
  chain.experiments.layers(true);
82
72
 
83
73
  applyLoaders(chain, { tagMatcher, preserveTap });
@@ -153,9 +143,6 @@ export const schema = {
153
143
  keep: 'miniprogram_npm',
154
144
  },
155
145
  },
156
- cssFilename: {
157
- default: '.wxss',
158
- },
159
146
  },
160
147
  },
161
148
  optimization: {
@@ -171,6 +158,7 @@ export const schema = {
171
158
  },
172
159
  },
173
160
  babel: {
161
+ type: 'object',
174
162
  properties: {
175
163
  polyfill: {
176
164
  default: {
package/loader.mjs CHANGED
@@ -1,20 +1,22 @@
1
1
  import extToRegexp from 'ext-to-regexp';
2
2
 
3
3
  export function applyLoaders(chain, options) {
4
- const babelRule = chain.module.rule('babel');
5
-
6
4
  const vueRegexp = extToRegexp({ extname: ['vue'] });
7
5
 
8
6
  const vueRule = chain.module.rule('vue-file').test(vueRegexp);
9
7
 
10
- vueRule
11
- .rule('extract-vue-javascript')
12
- .test(vueRegexp)
13
- .issuer(vueRegexp)
14
- .resourceQuery(/type=script/)
15
- .type('javascript/esm')
16
- .use('babel-loader')
17
- .merge(babelRule.use('babel-loader').entries());
8
+ if (chain.module.rules.has('babel')) {
9
+ const babelRule = chain.module.rule('babel');
10
+
11
+ vueRule
12
+ .rule('extract-vue-javascript')
13
+ .test(vueRegexp)
14
+ .issuer(vueRegexp)
15
+ .resourceQuery(/type=script/)
16
+ .type('javascript/esm')
17
+ .use('babel-loader')
18
+ .merge(babelRule.use('babel-loader').entries());
19
+ }
18
20
 
19
21
  vueRule
20
22
  .rule('extract-vue-template')
@@ -41,27 +43,29 @@ export function applyLoaders(chain, options) {
41
43
  .use('yaml-loader')
42
44
  .loader('yaml-patch-loader');
43
45
 
44
- const xRule = vueRule
45
- .rule('extract-vue-style')
46
- .test(vueRegexp)
47
- .issuer(vueRegexp)
48
- .resourceQuery(/type=style/);
46
+ if (chain.module.rules.has('style')) {
47
+ const xRule = vueRule
48
+ .rule('extract-vue-style')
49
+ .test(vueRegexp)
50
+ .issuer(vueRegexp)
51
+ .resourceQuery(/type=style/);
49
52
 
50
- const styleRule = chain.module.rule('style');
53
+ const styleRule = chain.module.rule('style');
51
54
 
52
- for (const name of ['all', 'postcss', 'sass', 'less']) {
53
- xRule.rule(name).merge(styleRule.rule(name).toConfig());
54
- }
55
+ for (const name of ['all', 'postcss', 'sass', 'less']) {
56
+ xRule.rule(name).merge(styleRule.rule(name).toConfig());
57
+ }
55
58
 
56
- xRule
57
- .rule('sass')
58
- .delete('test')
59
- .resourceQuery(/lang=scss/);
59
+ xRule
60
+ .rule('sass')
61
+ .delete('test')
62
+ .resourceQuery(/lang=scss/);
60
63
 
61
- xRule
62
- .rule('less')
63
- .delete('test')
64
- .resourceQuery(/lang=less/);
64
+ xRule
65
+ .rule('less')
66
+ .delete('test')
67
+ .resourceQuery(/lang=less/);
68
+ }
65
69
 
66
70
  vueRule
67
71
  .rule('split-vue')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@best-shot/preset-mini",
3
- "version": "0.11.25",
3
+ "version": "0.11.26",
4
4
  "description": "A `best-shot` preset for mini program project",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -36,10 +36,10 @@
36
36
  "yaml-patch-loader": "^0.1.0"
37
37
  },
38
38
  "peerDependencies": {
39
- "@babel/core": "^7.28.5",
40
- "@best-shot/core": "^0.13.10",
39
+ "@babel/core": "^7.29.0",
40
+ "@best-shot/core": "^0.13.11",
41
41
  "@best-shot/preset-babel": "^0.18.6",
42
- "@best-shot/preset-style": "^0.16.3"
42
+ "@best-shot/preset-style": "^0.16.4"
43
43
  },
44
44
  "engines": {
45
45
  "node": ">=22.18.0"