@rsbuild/plugin-styled-components 0.4.10 → 0.4.12
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.d.ts +1 -1
- package/dist/index.js +25 -20
- package/dist/index.mjs +26 -21
- package/package.json +4 -5
package/dist/index.d.ts
CHANGED
|
@@ -16,6 +16,6 @@ type PluginStyledComponentsOptions = {
|
|
|
16
16
|
pure?: boolean;
|
|
17
17
|
cssProps?: boolean;
|
|
18
18
|
};
|
|
19
|
-
declare const pluginStyledComponents: (
|
|
19
|
+
declare const pluginStyledComponents: (pluginOptions?: ChainedConfig<PluginStyledComponentsOptions>) => RsbuildPlugin;
|
|
20
20
|
|
|
21
21
|
export { type PluginStyledComponentsOptions, pluginStyledComponents };
|
package/dist/index.js
CHANGED
|
@@ -24,30 +24,35 @@ __export(src_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(src_exports);
|
|
26
26
|
var import_shared = require("@rsbuild/shared");
|
|
27
|
-
var pluginStyledComponents = (
|
|
27
|
+
var pluginStyledComponents = (pluginOptions = {}) => ({
|
|
28
28
|
name: "rsbuild:styled-components",
|
|
29
29
|
setup(api) {
|
|
30
|
-
api.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
defaults: (0, import_shared.getDefaultStyledComponentsConfig)(isProd,
|
|
38
|
-
options:
|
|
30
|
+
if (api.context.bundlerType === "webpack") {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const getMergedOptions = () => {
|
|
34
|
+
const useSSR = (0, import_shared.isServerTarget)(api.context.targets);
|
|
35
|
+
const isProd = (0, import_shared.getNodeEnv)() === "production";
|
|
36
|
+
return (0, import_shared.mergeChainedOptions)({
|
|
37
|
+
defaults: (0, import_shared.getDefaultStyledComponentsConfig)(isProd, useSSR),
|
|
38
|
+
options: pluginOptions
|
|
39
39
|
});
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
40
|
+
};
|
|
41
|
+
api.modifyRsbuildConfig((userConfig, { mergeRsbuildConfig }) => {
|
|
42
|
+
const extraConfig = {
|
|
43
|
+
tools: {
|
|
44
|
+
swc(opts) {
|
|
45
|
+
const mergedOptions = getMergedOptions();
|
|
46
|
+
if (!mergedOptions) {
|
|
47
|
+
return opts;
|
|
48
|
+
}
|
|
49
|
+
opts.rspackExperiments ?? (opts.rspackExperiments = {});
|
|
50
|
+
opts.rspackExperiments.styledComponents = mergedOptions;
|
|
51
|
+
return opts;
|
|
52
|
+
}
|
|
49
53
|
}
|
|
50
|
-
}
|
|
54
|
+
};
|
|
55
|
+
return mergeRsbuildConfig(extraConfig, userConfig);
|
|
51
56
|
});
|
|
52
57
|
}
|
|
53
58
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -8,35 +8,40 @@ import path from "path";
|
|
|
8
8
|
|
|
9
9
|
// src/index.ts
|
|
10
10
|
import {
|
|
11
|
+
getNodeEnv,
|
|
11
12
|
isServerTarget,
|
|
12
13
|
mergeChainedOptions,
|
|
13
|
-
modifySwcLoaderOptions,
|
|
14
14
|
getDefaultStyledComponentsConfig
|
|
15
15
|
} from "@rsbuild/shared";
|
|
16
|
-
var pluginStyledComponents = (
|
|
16
|
+
var pluginStyledComponents = (pluginOptions = {}) => ({
|
|
17
17
|
name: "rsbuild:styled-components",
|
|
18
18
|
setup(api) {
|
|
19
|
-
api.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
defaults: getDefaultStyledComponentsConfig(isProd,
|
|
27
|
-
options:
|
|
19
|
+
if (api.context.bundlerType === "webpack") {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const getMergedOptions = () => {
|
|
23
|
+
const useSSR = isServerTarget(api.context.targets);
|
|
24
|
+
const isProd = getNodeEnv() === "production";
|
|
25
|
+
return mergeChainedOptions({
|
|
26
|
+
defaults: getDefaultStyledComponentsConfig(isProd, useSSR),
|
|
27
|
+
options: pluginOptions
|
|
28
28
|
});
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
29
|
+
};
|
|
30
|
+
api.modifyRsbuildConfig((userConfig, { mergeRsbuildConfig }) => {
|
|
31
|
+
const extraConfig = {
|
|
32
|
+
tools: {
|
|
33
|
+
swc(opts) {
|
|
34
|
+
const mergedOptions = getMergedOptions();
|
|
35
|
+
if (!mergedOptions) {
|
|
36
|
+
return opts;
|
|
37
|
+
}
|
|
38
|
+
opts.rspackExperiments ?? (opts.rspackExperiments = {});
|
|
39
|
+
opts.rspackExperiments.styledComponents = mergedOptions;
|
|
40
|
+
return opts;
|
|
41
|
+
}
|
|
38
42
|
}
|
|
39
|
-
}
|
|
43
|
+
};
|
|
44
|
+
return mergeRsbuildConfig(extraConfig, userConfig);
|
|
40
45
|
});
|
|
41
46
|
}
|
|
42
47
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/plugin-styled-components",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.12",
|
|
4
4
|
"description": "styled-components plugin for Rsbuild",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -22,16 +22,15 @@
|
|
|
22
22
|
"dist"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@rsbuild/shared": "0.4.
|
|
25
|
+
"@rsbuild/shared": "0.4.12"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/node": "16.x",
|
|
29
29
|
"typescript": "^5.3.0",
|
|
30
|
-
"@rsbuild/core": "0.4.
|
|
31
|
-
"@scripts/test-helper": "0.4.10"
|
|
30
|
+
"@rsbuild/core": "0.4.12"
|
|
32
31
|
},
|
|
33
32
|
"peerDependencies": {
|
|
34
|
-
"@rsbuild/core": "^0.4.
|
|
33
|
+
"@rsbuild/core": "^0.4.12"
|
|
35
34
|
},
|
|
36
35
|
"publishConfig": {
|
|
37
36
|
"access": "public",
|