@rsbuild/plugin-stylus 1.1.1 → 1.1.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 +1 -1
- package/dist/index.cjs +9 -5
- package/dist/index.js +14 -10
- package/package.json +8 -8
package/README.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -20,14 +20,15 @@ __webpack_require__.n = (module)=>{
|
|
|
20
20
|
};
|
|
21
21
|
var __webpack_exports__ = {};
|
|
22
22
|
__webpack_require__.r(__webpack_exports__), __webpack_require__.d(__webpack_exports__, {
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
pluginStylus: ()=>pluginStylus,
|
|
24
|
+
PLUGIN_STYLUS_NAME: ()=>PLUGIN_STYLUS_NAME
|
|
25
25
|
});
|
|
26
26
|
let external_node_module_namespaceObject = require("node:module"), external_deepmerge_namespaceObject = require("deepmerge");
|
|
27
27
|
var external_deepmerge_default = __webpack_require__.n(external_deepmerge_namespaceObject);
|
|
28
28
|
let 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 RAW_QUERY_REGEX = /^\?raw$/, INLINE_QUERY_REGEX = /^\?inline$/;
|
|
31
32
|
api.modifyBundlerChain(async (chain, { CHAIN_ID, environment })=>{
|
|
32
33
|
var callback;
|
|
33
34
|
let { config } = environment, { sourceMap } = config.output, mergedOptions = (0, external_reduce_configs_namespaceObject.reduceConfigs)({
|
|
@@ -37,9 +38,12 @@ let external_reduce_configs_namespaceObject = require("reduce-configs"), src_req
|
|
|
37
38
|
config: options,
|
|
38
39
|
mergeFn: external_deepmerge_default()
|
|
39
40
|
}), test = /\.styl(us)?$/, rule = chain.module.rule(CHAIN_ID.RULE.STYLUS).test(test).resourceQuery({
|
|
40
|
-
not:
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
not: [
|
|
42
|
+
RAW_QUERY_REGEX,
|
|
43
|
+
INLINE_QUERY_REGEX
|
|
44
|
+
]
|
|
45
|
+
}).sideEffects(!0).resolve.preferRelative(!0).end(), inlineRule = CHAIN_ID.RULE.CSS_INLINE && chain.module.rules.has(CHAIN_ID.RULE.CSS_INLINE) ? chain.module.rule(CHAIN_ID.RULE.STYLUS_INLINE).test(test).resourceQuery(INLINE_QUERY_REGEX) : null;
|
|
46
|
+
chain.module.rule(CHAIN_ID.RULE.STYLUS_RAW).test(test).type('asset/source').resourceQuery(RAW_QUERY_REGEX), (callback = (rule, type)=>{
|
|
43
47
|
let cssRule = chain.module.rules.get('normal' === type ? CHAIN_ID.RULE.CSS : CHAIN_ID.RULE.CSS_INLINE);
|
|
44
48
|
for (let id of (rule.dependency(cssRule.get('dependency')), Object.keys(cssRule.uses.entries()))){
|
|
45
49
|
let loader = cssRule.uses.get(id), options = loader.get('options') ?? {}, clonedOptions = external_deepmerge_default()({}, options);
|
package/dist/index.js
CHANGED
|
@@ -1,24 +1,28 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
let src_require =
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import deepmerge from "deepmerge";
|
|
3
|
+
import { reduceConfigs } from "reduce-configs";
|
|
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 RAW_QUERY_REGEX = /^\?raw$/, INLINE_QUERY_REGEX = /^\?inline$/;
|
|
7
8
|
api.modifyBundlerChain(async (chain, { CHAIN_ID, environment })=>{
|
|
8
9
|
var callback;
|
|
9
|
-
let { config } = environment, { sourceMap } = config.output, mergedOptions =
|
|
10
|
+
let { config } = environment, { sourceMap } = config.output, mergedOptions = reduceConfigs({
|
|
10
11
|
initial: {
|
|
11
12
|
sourceMap: 'boolean' == typeof sourceMap ? sourceMap : sourceMap.css
|
|
12
13
|
},
|
|
13
14
|
config: options,
|
|
14
|
-
mergeFn:
|
|
15
|
+
mergeFn: deepmerge
|
|
15
16
|
}), test = /\.styl(us)?$/, rule = chain.module.rule(CHAIN_ID.RULE.STYLUS).test(test).resourceQuery({
|
|
16
|
-
not:
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
not: [
|
|
18
|
+
RAW_QUERY_REGEX,
|
|
19
|
+
INLINE_QUERY_REGEX
|
|
20
|
+
]
|
|
21
|
+
}).sideEffects(!0).resolve.preferRelative(!0).end(), inlineRule = CHAIN_ID.RULE.CSS_INLINE && chain.module.rules.has(CHAIN_ID.RULE.CSS_INLINE) ? chain.module.rule(CHAIN_ID.RULE.STYLUS_INLINE).test(test).resourceQuery(INLINE_QUERY_REGEX) : null;
|
|
22
|
+
chain.module.rule(CHAIN_ID.RULE.STYLUS_RAW).test(test).type('asset/source').resourceQuery(RAW_QUERY_REGEX), (callback = (rule, type)=>{
|
|
19
23
|
let cssRule = chain.module.rules.get('normal' === type ? CHAIN_ID.RULE.CSS : CHAIN_ID.RULE.CSS_INLINE);
|
|
20
24
|
for (let id of (rule.dependency(cssRule.get('dependency')), Object.keys(cssRule.uses.entries()))){
|
|
21
|
-
let loader = cssRule.uses.get(id),
|
|
25
|
+
let loader = cssRule.uses.get(id), clonedOptions = deepmerge({}, loader.get('options') ?? {});
|
|
22
26
|
id === CHAIN_ID.USE.CSS && (clonedOptions.importLoaders += 1), rule.use(id).loader(loader.get('loader')).options(clonedOptions);
|
|
23
27
|
}
|
|
24
28
|
rule.use(CHAIN_ID.USE.STYLUS).loader(src_require.resolve('stylus-loader')).options(mergedOptions);
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/plugin-stylus",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "Stylus plugin for Rsbuild",
|
|
5
|
-
"homepage": "https://rsbuild.
|
|
5
|
+
"homepage": "https://rsbuild.rs",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/web-infra-dev/rsbuild",
|
|
@@ -29,22 +29,22 @@
|
|
|
29
29
|
"stylus-loader": "8.1.1"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@rslib/core": "0.
|
|
33
|
-
"@types/node": "^22.
|
|
34
|
-
"typescript": "^5.
|
|
32
|
+
"@rslib/core": "0.11.1",
|
|
33
|
+
"@types/node": "^22.17.0",
|
|
34
|
+
"typescript": "^5.9.2",
|
|
35
35
|
"@scripts/test-helper": "1.0.1",
|
|
36
|
-
"@rsbuild/core": "1.
|
|
36
|
+
"@rsbuild/core": "1.4.14"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"@rsbuild/core": "1.x"
|
|
40
40
|
},
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"access": "public",
|
|
43
|
-
"provenance": true,
|
|
44
43
|
"registry": "https://registry.npmjs.org/"
|
|
45
44
|
},
|
|
46
45
|
"scripts": {
|
|
47
46
|
"build": "rslib build",
|
|
48
|
-
"dev": "rslib build --watch"
|
|
47
|
+
"dev": "rslib build --watch",
|
|
48
|
+
"bump": "npx bumpp --no-tag"
|
|
49
49
|
}
|
|
50
50
|
}
|