@rsbuild/plugin-stylus 1.3.3 → 2.0.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.js +1 -9
- package/package.json +3 -5
- package/dist/index.cjs +0 -115
package/dist/index.js
CHANGED
|
@@ -12,7 +12,6 @@ const pluginStylus = (options)=>({
|
|
|
12
12
|
const STYLUS_URL = 'stylus-url';
|
|
13
13
|
const STYLUS_INLINE = 'stylus-inline';
|
|
14
14
|
const STYLUS_RAW = 'stylus-raw';
|
|
15
|
-
const isV1 = api.context.version.startsWith('1.');
|
|
16
15
|
api.modifyBundlerChain((chain, { CHAIN_ID, environment })=>{
|
|
17
16
|
const { config } = environment;
|
|
18
17
|
const { sourceMap } = config.output;
|
|
@@ -27,14 +26,7 @@ const pluginStylus = (options)=>({
|
|
|
27
26
|
const cssRule = chain.module.rule(CHAIN_ID.RULE.CSS);
|
|
28
27
|
const cssUrlRuleId = CHAIN_ID.ONE_OF.CSS_URL;
|
|
29
28
|
const hasCssUrlRule = cssUrlRuleId && cssRule.oneOfs.has(cssUrlRuleId);
|
|
30
|
-
|
|
31
|
-
chain.module.rule(STYLUS_RAW).test(test);
|
|
32
|
-
chain.module.rule(STYLUS_INLINE).test(test);
|
|
33
|
-
}
|
|
34
|
-
const getRule = (id)=>{
|
|
35
|
-
if (isV1) return chain.module.rule(id);
|
|
36
|
-
return (id.startsWith('stylus') ? stylusRule : cssRule).oneOf(id);
|
|
37
|
-
};
|
|
29
|
+
const getRule = (id)=>(id.startsWith('stylus') ? stylusRule : cssRule).oneOf(id);
|
|
38
30
|
const stylusUrlRule = hasCssUrlRule && getRule(STYLUS_URL);
|
|
39
31
|
const stylusInlineRule = getRule(STYLUS_INLINE);
|
|
40
32
|
getRule(STYLUS_RAW).type('asset/source').resourceQuery(getRule(CSS_RAW).get('resourceQuery'));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/plugin-stylus",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Stylus plugin for Rsbuild",
|
|
5
5
|
"repository": "https://github.com/rstackjs/rsbuild-plugin-stylus",
|
|
6
6
|
"license": "MIT",
|
|
@@ -8,8 +8,7 @@
|
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
11
|
-
"
|
|
12
|
-
"require": "./dist/index.cjs"
|
|
11
|
+
"default": "./dist/index.js"
|
|
13
12
|
}
|
|
14
13
|
},
|
|
15
14
|
"types": "./dist/index.d.ts",
|
|
@@ -36,7 +35,6 @@
|
|
|
36
35
|
"devDependencies": {
|
|
37
36
|
"@playwright/test": "^1.60.0",
|
|
38
37
|
"@rsbuild/core": "^2.0.6",
|
|
39
|
-
"@rsbuild/core-v1": "npm:@rsbuild/core@^1.7.5",
|
|
40
38
|
"@rsbuild/plugin-rem": "^1.0.5",
|
|
41
39
|
"@rslib/core": "^0.21.5",
|
|
42
40
|
"@rslint/core": "^0.5.3",
|
|
@@ -47,7 +45,7 @@
|
|
|
47
45
|
"typescript": "^6.0.3"
|
|
48
46
|
},
|
|
49
47
|
"peerDependencies": {
|
|
50
|
-
"@rsbuild/core": "^
|
|
48
|
+
"@rsbuild/core": "^2.0.0"
|
|
51
49
|
},
|
|
52
50
|
"peerDependenciesMeta": {
|
|
53
51
|
"@rsbuild/core": {
|
package/dist/index.cjs
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const __rslib_import_meta_url__ = /*#__PURE__*/ function() {
|
|
3
|
-
return "u" < typeof document ? new (require('url'.replace('', ''))).URL('file:' + __filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href;
|
|
4
|
-
}();
|
|
5
|
-
var __webpack_require__ = {};
|
|
6
|
-
(()=>{
|
|
7
|
-
__webpack_require__.n = (module)=>{
|
|
8
|
-
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
9
|
-
__webpack_require__.d(getter, {
|
|
10
|
-
a: getter
|
|
11
|
-
});
|
|
12
|
-
return getter;
|
|
13
|
-
};
|
|
14
|
-
})();
|
|
15
|
-
(()=>{
|
|
16
|
-
__webpack_require__.d = (exports1, definition)=>{
|
|
17
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
get: definition[key]
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
})();
|
|
23
|
-
(()=>{
|
|
24
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
25
|
-
})();
|
|
26
|
-
(()=>{
|
|
27
|
-
__webpack_require__.r = (exports1)=>{
|
|
28
|
-
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
29
|
-
value: 'Module'
|
|
30
|
-
});
|
|
31
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
32
|
-
value: true
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
})();
|
|
36
|
-
var __webpack_exports__ = {};
|
|
37
|
-
__webpack_require__.r(__webpack_exports__);
|
|
38
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
39
|
-
PLUGIN_STYLUS_NAME: ()=>PLUGIN_STYLUS_NAME,
|
|
40
|
-
pluginStylus: ()=>pluginStylus
|
|
41
|
-
});
|
|
42
|
-
const external_node_module_namespaceObject = require("node:module");
|
|
43
|
-
const external_deepmerge_namespaceObject = require("deepmerge");
|
|
44
|
-
var external_deepmerge_default = /*#__PURE__*/ __webpack_require__.n(external_deepmerge_namespaceObject);
|
|
45
|
-
const src_require = (0, external_node_module_namespaceObject.createRequire)(__rslib_import_meta_url__);
|
|
46
|
-
const PLUGIN_STYLUS_NAME = 'rsbuild:stylus';
|
|
47
|
-
const pluginStylus = (options)=>({
|
|
48
|
-
name: PLUGIN_STYLUS_NAME,
|
|
49
|
-
setup (api) {
|
|
50
|
-
const CSS_MAIN = 'css';
|
|
51
|
-
const CSS_INLINE = 'css-inline';
|
|
52
|
-
const CSS_RAW = 'css-raw';
|
|
53
|
-
const STYLUS_MAIN = 'stylus';
|
|
54
|
-
const STYLUS_URL = 'stylus-url';
|
|
55
|
-
const STYLUS_INLINE = 'stylus-inline';
|
|
56
|
-
const STYLUS_RAW = 'stylus-raw';
|
|
57
|
-
const isV1 = api.context.version.startsWith('1.');
|
|
58
|
-
api.modifyBundlerChain((chain, { CHAIN_ID, environment })=>{
|
|
59
|
-
const { config } = environment;
|
|
60
|
-
const { sourceMap } = config.output;
|
|
61
|
-
const mergedOptions = {
|
|
62
|
-
sourceMap: 'boolean' == typeof sourceMap ? sourceMap : sourceMap.css,
|
|
63
|
-
...options
|
|
64
|
-
};
|
|
65
|
-
const test = /\.styl(us)?$/;
|
|
66
|
-
const stylusRule = chain.module.rule(CHAIN_ID.RULE.STYLUS).test(test).dependency({
|
|
67
|
-
not: 'url'
|
|
68
|
-
}).resolve.preferRelative(true).end();
|
|
69
|
-
const cssRule = chain.module.rule(CHAIN_ID.RULE.CSS);
|
|
70
|
-
const cssUrlRuleId = CHAIN_ID.ONE_OF.CSS_URL;
|
|
71
|
-
const hasCssUrlRule = cssUrlRuleId && cssRule.oneOfs.has(cssUrlRuleId);
|
|
72
|
-
if (isV1) {
|
|
73
|
-
chain.module.rule(STYLUS_RAW).test(test);
|
|
74
|
-
chain.module.rule(STYLUS_INLINE).test(test);
|
|
75
|
-
}
|
|
76
|
-
const getRule = (id)=>{
|
|
77
|
-
if (isV1) return chain.module.rule(id);
|
|
78
|
-
return (id.startsWith('stylus') ? stylusRule : cssRule).oneOf(id);
|
|
79
|
-
};
|
|
80
|
-
const stylusUrlRule = hasCssUrlRule && getRule(STYLUS_URL);
|
|
81
|
-
const stylusInlineRule = getRule(STYLUS_INLINE);
|
|
82
|
-
getRule(STYLUS_RAW).type('asset/source').resourceQuery(getRule(CSS_RAW).get('resourceQuery'));
|
|
83
|
-
const stylusMainRule = getRule(STYLUS_MAIN);
|
|
84
|
-
const updateRules = (callback)=>{
|
|
85
|
-
if (stylusUrlRule) callback(stylusUrlRule, getRule(cssUrlRuleId), 'url');
|
|
86
|
-
callback(stylusMainRule, getRule(CSS_MAIN), 'main');
|
|
87
|
-
callback(stylusInlineRule, getRule(CSS_INLINE), 'inline');
|
|
88
|
-
};
|
|
89
|
-
updateRules((rule, cssBranchRule, type)=>{
|
|
90
|
-
if ('url' !== type) rule.sideEffects(true);
|
|
91
|
-
rule.resourceQuery(cssBranchRule.get('resourceQuery'));
|
|
92
|
-
for (const id of Object.keys(cssBranchRule.uses.entries())){
|
|
93
|
-
const loader = cssBranchRule.uses.get(id);
|
|
94
|
-
const options = loader.get('options') ?? {};
|
|
95
|
-
const clonedOptions = external_deepmerge_default()({}, options);
|
|
96
|
-
if (id === CHAIN_ID.USE.CSS) {
|
|
97
|
-
const importLoaders = clonedOptions.importLoaders;
|
|
98
|
-
clonedOptions.importLoaders = 'number' == typeof importLoaders ? importLoaders + 1 : 1;
|
|
99
|
-
}
|
|
100
|
-
rule.use(id).loader(loader.get('loader')).options(clonedOptions);
|
|
101
|
-
}
|
|
102
|
-
rule.use(CHAIN_ID.USE.STYLUS).loader(src_require.resolve('stylus-loader')).options(mergedOptions);
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
exports.PLUGIN_STYLUS_NAME = __webpack_exports__.PLUGIN_STYLUS_NAME;
|
|
108
|
-
exports.pluginStylus = __webpack_exports__.pluginStylus;
|
|
109
|
-
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
110
|
-
"PLUGIN_STYLUS_NAME",
|
|
111
|
-
"pluginStylus"
|
|
112
|
-
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
113
|
-
Object.defineProperty(exports, '__esModule', {
|
|
114
|
-
value: true
|
|
115
|
-
});
|