@rsbuild/plugin-stylus 1.2.1 → 1.3.0
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/dist/index.cjs +12 -10
- package/dist/index.js +12 -10
- package/package.json +7 -6
package/dist/index.cjs
CHANGED
|
@@ -28,6 +28,7 @@ var external_deepmerge_default = __webpack_require__.n(external_deepmerge_namesp
|
|
|
28
28
|
const external_reduce_configs_namespaceObject = require("reduce-configs"), src_require = (0, external_node_module_namespaceObject.createRequire)(__rslib_import_meta_url__), PLUGIN_STYLUS_NAME = 'rsbuild:stylus', pluginStylus = (options)=>({
|
|
29
29
|
name: PLUGIN_STYLUS_NAME,
|
|
30
30
|
setup (api) {
|
|
31
|
+
let STYLUS_INLINE = 'stylus-inline', STYLUS_RAW = 'stylus-raw', isV1 = api.context.version.startsWith('1.');
|
|
31
32
|
api.modifyBundlerChain((chain, { CHAIN_ID, environment })=>{
|
|
32
33
|
var callback;
|
|
33
34
|
let { config } = environment, { sourceMap } = config.output, mergedOptions = (0, external_reduce_configs_namespaceObject.reduceConfigs)({
|
|
@@ -36,19 +37,20 @@ const external_reduce_configs_namespaceObject = require("reduce-configs"), src_r
|
|
|
36
37
|
},
|
|
37
38
|
config: options,
|
|
38
39
|
mergeFn: external_deepmerge_default()
|
|
39
|
-
}), test = /\.styl(us)?$/,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
40
|
+
}), test = /\.styl(us)?$/, stylusRule = chain.module.rule(CHAIN_ID.RULE.STYLUS).test(test).dependency({
|
|
41
|
+
not: 'url'
|
|
42
|
+
}).resolve.preferRelative(!0).end();
|
|
43
|
+
isV1 && (chain.module.rule(STYLUS_RAW).test(test), chain.module.rule(STYLUS_INLINE).test(test));
|
|
44
|
+
let getRule = (id)=>isV1 ? chain.module.rule(id) : (id.startsWith('stylus') ? stylusRule : chain.module.rule(CHAIN_ID.RULE.CSS)).oneOf(id), stylusInlineRule = getRule(STYLUS_INLINE);
|
|
45
|
+
getRule(STYLUS_RAW).type('asset/source').resourceQuery(getRule('css-raw').get('resourceQuery'));
|
|
46
|
+
let stylusMainRule = getRule('stylus');
|
|
47
|
+
(callback = (rule, cssBranchRule)=>{
|
|
48
|
+
for (let id of (rule.sideEffects(!0).resourceQuery(cssBranchRule.get('resourceQuery')), Object.keys(cssBranchRule.uses.entries()))){
|
|
49
|
+
let loader = cssBranchRule.uses.get(id), options = loader.get('options') ?? {}, clonedOptions = external_deepmerge_default()({}, options);
|
|
48
50
|
id === CHAIN_ID.USE.CSS && (clonedOptions.importLoaders += 1), rule.use(id).loader(loader.get('loader')).options(clonedOptions);
|
|
49
51
|
}
|
|
50
52
|
rule.use(CHAIN_ID.USE.STYLUS).loader(src_require.resolve('stylus-loader')).options(mergedOptions);
|
|
51
|
-
})(
|
|
53
|
+
})(stylusMainRule, getRule('css')), callback(stylusInlineRule, getRule('css-inline'));
|
|
52
54
|
});
|
|
53
55
|
}
|
|
54
56
|
});
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import { reduceConfigs } from "reduce-configs";
|
|
|
4
4
|
let src_require = createRequire(import.meta.url), PLUGIN_STYLUS_NAME = 'rsbuild:stylus', pluginStylus = (options)=>({
|
|
5
5
|
name: PLUGIN_STYLUS_NAME,
|
|
6
6
|
setup (api) {
|
|
7
|
+
let STYLUS_INLINE = 'stylus-inline', STYLUS_RAW = 'stylus-raw', isV1 = api.context.version.startsWith('1.');
|
|
7
8
|
api.modifyBundlerChain((chain, { CHAIN_ID, environment })=>{
|
|
8
9
|
var callback;
|
|
9
10
|
let { config } = environment, { sourceMap } = config.output, mergedOptions = reduceConfigs({
|
|
@@ -12,19 +13,20 @@ let src_require = createRequire(import.meta.url), PLUGIN_STYLUS_NAME = 'rsbuild:
|
|
|
12
13
|
},
|
|
13
14
|
config: options,
|
|
14
15
|
mergeFn: deepmerge
|
|
15
|
-
}), test = /\.styl(us)?$/,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
}), test = /\.styl(us)?$/, stylusRule = chain.module.rule(CHAIN_ID.RULE.STYLUS).test(test).dependency({
|
|
17
|
+
not: 'url'
|
|
18
|
+
}).resolve.preferRelative(!0).end();
|
|
19
|
+
isV1 && (chain.module.rule(STYLUS_RAW).test(test), chain.module.rule(STYLUS_INLINE).test(test));
|
|
20
|
+
let getRule = (id)=>isV1 ? chain.module.rule(id) : (id.startsWith('stylus') ? stylusRule : chain.module.rule(CHAIN_ID.RULE.CSS)).oneOf(id), stylusInlineRule = getRule(STYLUS_INLINE);
|
|
21
|
+
getRule(STYLUS_RAW).type('asset/source').resourceQuery(getRule('css-raw').get('resourceQuery'));
|
|
22
|
+
let stylusMainRule = getRule('stylus');
|
|
23
|
+
(callback = (rule, cssBranchRule)=>{
|
|
24
|
+
for (let id of (rule.sideEffects(!0).resourceQuery(cssBranchRule.get('resourceQuery')), Object.keys(cssBranchRule.uses.entries()))){
|
|
25
|
+
let loader = cssBranchRule.uses.get(id), clonedOptions = deepmerge({}, loader.get('options') ?? {});
|
|
24
26
|
id === CHAIN_ID.USE.CSS && (clonedOptions.importLoaders += 1), rule.use(id).loader(loader.get('loader')).options(clonedOptions);
|
|
25
27
|
}
|
|
26
28
|
rule.use(CHAIN_ID.USE.STYLUS).loader(src_require.resolve('stylus-loader')).options(mergedOptions);
|
|
27
|
-
})(
|
|
29
|
+
})(stylusMainRule, getRule('css')), callback(stylusInlineRule, getRule('css-inline'));
|
|
28
30
|
});
|
|
29
31
|
}
|
|
30
32
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/plugin-stylus",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Stylus plugin for Rsbuild",
|
|
5
5
|
"homepage": "https://rsbuild.rs",
|
|
6
6
|
"repository": {
|
|
@@ -29,14 +29,15 @@
|
|
|
29
29
|
"stylus-loader": "8.1.2"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@
|
|
33
|
-
"@
|
|
32
|
+
"@rsbuild/core-v1": "npm:@rsbuild/core@^1.7.2",
|
|
33
|
+
"@rslib/core": "0.19.3",
|
|
34
|
+
"@types/node": "^24.10.9",
|
|
34
35
|
"typescript": "^5.9.3",
|
|
35
|
-
"@
|
|
36
|
-
"@
|
|
36
|
+
"@scripts/test-helper": "1.0.1",
|
|
37
|
+
"@rsbuild/core": "2.0.0-alpha.3"
|
|
37
38
|
},
|
|
38
39
|
"peerDependencies": {
|
|
39
|
-
"@rsbuild/core": "^1.
|
|
40
|
+
"@rsbuild/core": "^1.3.0 || ^2.0.0-0"
|
|
40
41
|
},
|
|
41
42
|
"publishConfig": {
|
|
42
43
|
"access": "public",
|