@modern-js/plugin-tailwindcss 2.0.0-beta.3 → 2.0.0-beta.4
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/CHANGELOG.md +97 -0
- package/dist/js/modern/cli.js +132 -79
- package/dist/js/modern/design-token/cli/index.js +57 -51
- package/dist/js/modern/design-token/global.d.js +0 -0
- package/dist/js/modern/design-token/index.js +5 -2
- package/dist/js/modern/design-token/postcss-plugin/index.js +11 -8
- package/dist/js/modern/design-token/runtime/index.js +4 -1
- package/dist/js/modern/design-token/runtime/plugin.js +41 -29
- package/dist/js/modern/index.js +4 -1
- package/dist/js/modern/modern-app.env.d.js +0 -0
- package/dist/js/modern/tailwind.js +28 -21
- package/dist/js/modern/utils.js +32 -8
- package/dist/js/node/cli.js +152 -90
- package/dist/js/node/design-token/cli/index.js +70 -56
- package/dist/js/node/design-token/global.d.js +0 -0
- package/dist/js/node/design-token/index.js +29 -24
- package/dist/js/node/design-token/postcss-plugin/index.js +28 -13
- package/dist/js/node/design-token/runtime/index.js +31 -22
- package/dist/js/node/design-token/runtime/plugin.js +65 -40
- package/dist/js/node/index.js +27 -11
- package/dist/js/node/modern-app.env.d.js +0 -0
- package/dist/js/node/tailwind.js +47 -27
- package/dist/js/node/utils.js +56 -16
- package/dist/js/treeshaking/cli.js +265 -132
- package/dist/js/treeshaking/design-token/cli/index.js +116 -99
- package/dist/js/treeshaking/design-token/global.d.js +1 -0
- package/dist/js/treeshaking/design-token/index.js +3 -2
- package/dist/js/treeshaking/design-token/postcss-plugin/index.js +17 -26
- package/dist/js/treeshaking/design-token/runtime/index.js +2 -1
- package/dist/js/treeshaking/design-token/runtime/plugin.js +76 -55
- package/dist/js/treeshaking/index.js +2 -1
- package/dist/js/treeshaking/modern-app.env.d.js +1 -0
- package/dist/js/treeshaking/tailwind.js +86 -42
- package/dist/js/treeshaking/types.js +1 -0
- package/dist/js/treeshaking/utils.js +159 -44
- package/dist/types/cli.d.ts +3 -1
- package/dist/types/design-token/cli/index.d.ts +2 -0
- package/dist/types/design-token/postcss-plugin/index.d.ts +2 -0
- package/dist/types/design-token/runtime/plugin.d.ts +2 -0
- package/package.json +11 -10
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,102 @@
|
|
1
1
|
# @modern-js/plugin-tailwindcss
|
2
2
|
|
3
|
+
## 2.0.0-beta.4
|
4
|
+
|
5
|
+
### Major Changes
|
6
|
+
|
7
|
+
- dda38c9c3e: chore: v2
|
8
|
+
|
9
|
+
### Minor Changes
|
10
|
+
|
11
|
+
- 92f0eade39: feat:
|
12
|
+
|
13
|
+
1. add style config and add new hook
|
14
|
+
2. add dts alias logic
|
15
|
+
3. add copy logic
|
16
|
+
4. add log logic
|
17
|
+
5. add skipDeps config
|
18
|
+
|
19
|
+
feat:
|
20
|
+
|
21
|
+
1. 添加样式配置以及新的 hook
|
22
|
+
2. 添加 dts 别名处理
|
23
|
+
3. 添加 copy 逻辑
|
24
|
+
4. 添加日志逻辑
|
25
|
+
5. 添加 skipDeps 配置
|
26
|
+
|
27
|
+
- 92f0eade39: feat:
|
28
|
+
|
29
|
+
1. core: 增加 test 函数
|
30
|
+
2. module plugins: 增加 `babel`, `mainField`, `target` 插件
|
31
|
+
3. storybook: 修改部分逻辑并且增加 tspath webpack 插件
|
32
|
+
4. 增加 designSystem 配置
|
33
|
+
|
34
|
+
feat:
|
35
|
+
|
36
|
+
1. core: add test method
|
37
|
+
2. module plugins: add `babel`, `mainField`, `target` plugin
|
38
|
+
3. storybook: change some logic and add tspath webpack plugin
|
39
|
+
4. add `designSystem` config
|
40
|
+
|
41
|
+
### Patch Changes
|
42
|
+
|
43
|
+
- d6546ad916: add buildConfig style in module-tools and remove tools
|
44
|
+
在 module-tools 里新增 buildConfig style 并删除 tools
|
45
|
+
- 67472ca: fix: move babel-plugin-marcos to plugin-tailwindcss
|
46
|
+
|
47
|
+
fix: 将 babel-plugin-marcos 依赖移动到 plugin-tailwindcss 中
|
48
|
+
|
49
|
+
- Updated dependencies [2344eb26ed]
|
50
|
+
- Updated dependencies [a11fcf8b50]
|
51
|
+
- Updated dependencies [a931594]
|
52
|
+
- Updated dependencies [e7ce063]
|
53
|
+
- Updated dependencies [b18fa8f3ed]
|
54
|
+
- Updated dependencies [7879e8f]
|
55
|
+
- Updated dependencies [50d4675]
|
56
|
+
- Updated dependencies [c9e800d39a]
|
57
|
+
- Updated dependencies [6604f1b]
|
58
|
+
- Updated dependencies [6aca875]
|
59
|
+
- Updated dependencies [fda836f]
|
60
|
+
- Updated dependencies [d6bc321]
|
61
|
+
- Updated dependencies [3e57f2bd58]
|
62
|
+
- Updated dependencies [2e6031955e]
|
63
|
+
- Updated dependencies [c5798d2]
|
64
|
+
- Updated dependencies [fbf5eed5aa]
|
65
|
+
- Updated dependencies [a2509bfbdb]
|
66
|
+
- Updated dependencies [a7c6883]
|
67
|
+
- Updated dependencies [425e57092d]
|
68
|
+
- Updated dependencies [e4357f1856]
|
69
|
+
- Updated dependencies [7b7d12c]
|
70
|
+
- Updated dependencies [4369648ae2]
|
71
|
+
- Updated dependencies [92f0eade39]
|
72
|
+
- Updated dependencies [92c0994468]
|
73
|
+
- Updated dependencies [2cc2eb3]
|
74
|
+
- Updated dependencies [edd1cfb1af]
|
75
|
+
- Updated dependencies [cc971eabfc]
|
76
|
+
- Updated dependencies [5b9049f2e9]
|
77
|
+
- Updated dependencies [6bda14ed71]
|
78
|
+
- Updated dependencies [92004d1906]
|
79
|
+
- Updated dependencies [b8bbe036c7]
|
80
|
+
- Updated dependencies [40ed5874c6]
|
81
|
+
- Updated dependencies [60d5378632]
|
82
|
+
- Updated dependencies [d5a31df781]
|
83
|
+
- Updated dependencies [dda38c9c3e]
|
84
|
+
- Updated dependencies [8b8e1bb571]
|
85
|
+
- Updated dependencies [3bbea92b2a]
|
86
|
+
- Updated dependencies [9144c21]
|
87
|
+
- Updated dependencies [b710adb843]
|
88
|
+
- Updated dependencies [18aaf42249]
|
89
|
+
- Updated dependencies [34702d5]
|
90
|
+
- Updated dependencies [fcace5b5b9]
|
91
|
+
- Updated dependencies [ea7cf06]
|
92
|
+
- Updated dependencies [bbe4c4a]
|
93
|
+
- Updated dependencies [e4558a0]
|
94
|
+
- Updated dependencies [abf3421a75]
|
95
|
+
- Updated dependencies [543be9558e]
|
96
|
+
- Updated dependencies [14b712da84]
|
97
|
+
- @modern-js/runtime@2.0.0-beta.4
|
98
|
+
- @modern-js/utils@2.0.0-beta.4
|
99
|
+
|
3
100
|
## 2.0.0-beta.3
|
4
101
|
|
5
102
|
### Major Changes
|
package/dist/js/modern/cli.js
CHANGED
@@ -1,124 +1,177 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
var __async = (__this, __arguments, generator) => {
|
2
|
+
return new Promise((resolve, reject) => {
|
3
|
+
var fulfilled = (value) => {
|
4
|
+
try {
|
5
|
+
step(generator.next(value));
|
6
|
+
} catch (e) {
|
7
|
+
reject(e);
|
8
|
+
}
|
9
|
+
};
|
10
|
+
var rejected = (value) => {
|
11
|
+
try {
|
12
|
+
step(generator.throw(value));
|
13
|
+
} catch (e) {
|
14
|
+
reject(e);
|
15
|
+
}
|
16
|
+
};
|
17
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
18
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
19
|
+
});
|
20
|
+
};
|
21
|
+
import path from "path";
|
22
|
+
import {
|
23
|
+
PLUGIN_SCHEMAS,
|
24
|
+
fs,
|
25
|
+
CONFIG_CACHE_DIR,
|
26
|
+
globby,
|
27
|
+
nanoid,
|
28
|
+
slash
|
29
|
+
} from "@modern-js/utils";
|
6
30
|
import DesignTokenPlugin from "./design-token/cli";
|
7
31
|
import { getTailwindConfig } from "./tailwind";
|
8
32
|
import { template, checkTwinMacroNotExist } from "./utils";
|
9
|
-
const supportCssInJsLibrary =
|
10
|
-
|
11
|
-
return slash(
|
33
|
+
const supportCssInJsLibrary = "styled-components";
|
34
|
+
const getRandomTwConfigFileName = (internalDirectory) => {
|
35
|
+
return slash(
|
36
|
+
path.join(
|
37
|
+
internalDirectory,
|
38
|
+
`tailwind.config.${Date.now()}.${nanoid()}.js`
|
39
|
+
)
|
40
|
+
);
|
12
41
|
};
|
13
|
-
|
14
|
-
pluginName
|
15
|
-
} = {
|
16
|
-
pluginName: '@modern-js/plugin-tailwindcss'
|
42
|
+
var cli_default = ({ pluginName } = {
|
43
|
+
pluginName: "@modern-js/plugin-tailwindcss"
|
17
44
|
}) => ({
|
18
|
-
name:
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
let internalTwConfigPath = '';
|
29
|
-
// When reinstalling dependencies, most of the time the project will be restarted
|
30
|
-
const notHaveTwinMacro = await checkTwinMacroNotExist(appDirectory);
|
45
|
+
name: "@modern-js/plugin-tailwindcss",
|
46
|
+
usePlugins: [
|
47
|
+
DesignTokenPlugin({
|
48
|
+
pluginName
|
49
|
+
})
|
50
|
+
],
|
51
|
+
setup: (api) => __async(void 0, null, function* () {
|
52
|
+
const { appDirectory, internalDirectory } = api.useAppContext();
|
53
|
+
let internalTwConfigPath = "";
|
54
|
+
const notHaveTwinMacro = yield checkTwinMacroNotExist(appDirectory);
|
31
55
|
return {
|
32
56
|
prepare() {
|
33
57
|
if (notHaveTwinMacro) {
|
34
58
|
return;
|
35
59
|
}
|
36
60
|
internalTwConfigPath = getRandomTwConfigFileName(internalDirectory);
|
37
|
-
const globPattern = slash(
|
61
|
+
const globPattern = slash(
|
62
|
+
path.join(appDirectory, CONFIG_CACHE_DIR, "*.cjs")
|
63
|
+
);
|
38
64
|
const files = globby.sync(globPattern, {
|
39
65
|
absolute: true
|
40
66
|
});
|
41
67
|
if (files.length > 0) {
|
42
|
-
fs.writeFileSync(
|
68
|
+
fs.writeFileSync(
|
69
|
+
internalTwConfigPath,
|
70
|
+
template(files[files.length - 1]),
|
71
|
+
"utf-8"
|
72
|
+
);
|
43
73
|
}
|
44
74
|
},
|
45
75
|
validateSchema() {
|
46
|
-
return PLUGIN_SCHEMAS[
|
76
|
+
return PLUGIN_SCHEMAS["@modern-js/plugin-tailwindcss"];
|
47
77
|
},
|
48
78
|
config() {
|
49
79
|
return {
|
50
80
|
tools: {
|
51
|
-
|
52
|
-
|
53
|
-
postcss: config => {
|
54
|
-
var _modernConfig$tools, _modernConfig$source;
|
81
|
+
postcss: (config) => {
|
82
|
+
var _a, _b;
|
55
83
|
const modernConfig = api.useResolvedConfigContext();
|
56
|
-
const tailwindConfig = getTailwindConfig(
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
84
|
+
const tailwindConfig = getTailwindConfig(
|
85
|
+
(_a = modernConfig == null ? void 0 : modernConfig.tools) == null ? void 0 : _a.tailwindcss,
|
86
|
+
(_b = modernConfig == null ? void 0 : modernConfig.source) == null ? void 0 : _b.designSystem,
|
87
|
+
{
|
88
|
+
pureConfig: {
|
89
|
+
content: [
|
90
|
+
"./config/html/**/*.html",
|
91
|
+
"./config/html/**/*.ejs",
|
92
|
+
"./config/html/**/*.hbs",
|
93
|
+
"./src/**/*.js",
|
94
|
+
"./src/**/*.jsx",
|
95
|
+
"./src/**/*.ts",
|
96
|
+
"./src/**/*.tsx",
|
97
|
+
"./storybook/**/*",
|
98
|
+
"./styles/**/*.less",
|
99
|
+
"./styles/**/*.css",
|
100
|
+
"./styles/**/*.sass",
|
101
|
+
"./styles/**/*.scss"
|
102
|
+
]
|
103
|
+
}
|
61
104
|
}
|
62
|
-
|
105
|
+
);
|
63
106
|
if (Array.isArray(config.postcssOptions.plugins)) {
|
64
|
-
config.postcssOptions.plugins.push(
|
107
|
+
config.postcssOptions.plugins.push(
|
108
|
+
require("tailwindcss")(tailwindConfig)
|
109
|
+
);
|
65
110
|
} else {
|
66
|
-
config.postcssOptions.plugins = [
|
111
|
+
config.postcssOptions.plugins = [
|
112
|
+
require("tailwindcss")(tailwindConfig)
|
113
|
+
];
|
67
114
|
}
|
68
115
|
},
|
69
|
-
babel(
|
70
|
-
var _config$plugins;
|
116
|
+
babel(_, { addPlugins }) {
|
71
117
|
if (notHaveTwinMacro) {
|
72
118
|
return;
|
73
119
|
}
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
if (Array.isArray(plugin) && plugin[0]) {
|
82
|
-
const pluginTarget = plugin[0];
|
83
|
-
let pluginOptions = plugin[1];
|
84
|
-
if (typeof pluginTarget === 'string' &&
|
85
|
-
// TODO: use babel chain
|
86
|
-
slash(pluginTarget).includes('compiled/babel-plugin-macros')) {
|
87
|
-
if (pluginOptions) {
|
88
|
-
pluginOptions = _objectSpread(_objectSpread({}, pluginOptions), twinConfig);
|
89
|
-
} else {
|
90
|
-
plugin.push(twinConfig);
|
120
|
+
addPlugins([
|
121
|
+
[
|
122
|
+
require.resolve("babel-plugin-macros"),
|
123
|
+
{
|
124
|
+
twin: {
|
125
|
+
preset: supportCssInJsLibrary,
|
126
|
+
config: internalTwConfigPath
|
91
127
|
}
|
92
|
-
return true;
|
93
128
|
}
|
94
|
-
|
95
|
-
|
96
|
-
});
|
129
|
+
]
|
130
|
+
]);
|
97
131
|
}
|
98
132
|
}
|
99
133
|
};
|
100
134
|
},
|
101
|
-
beforeBuildTask({
|
102
|
-
config
|
103
|
-
}) {
|
135
|
+
beforeBuildTask({ config }) {
|
104
136
|
const modernConfig = api.useResolvedConfigContext();
|
105
|
-
const {
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
137
|
+
const { designSystem } = modernConfig;
|
138
|
+
const tailwindConfig = getTailwindConfig(
|
139
|
+
config.style.tailwindCss,
|
140
|
+
designSystem,
|
141
|
+
{
|
142
|
+
pureConfig: {
|
143
|
+
content: [
|
144
|
+
"./config/html/**/*.html",
|
145
|
+
"./config/html/**/*.ejs",
|
146
|
+
"./config/html/**/*.hbs",
|
147
|
+
"./src/**/*.js",
|
148
|
+
"./src/**/*.jsx",
|
149
|
+
"./src/**/*.ts",
|
150
|
+
"./src/**/*.tsx",
|
151
|
+
"./storybook/**/*",
|
152
|
+
"./styles/**/*.less",
|
153
|
+
"./styles/**/*.css",
|
154
|
+
"./styles/**/*.sass",
|
155
|
+
"./styles/**/*.scss"
|
156
|
+
]
|
157
|
+
}
|
113
158
|
}
|
114
|
-
|
159
|
+
);
|
115
160
|
if (Array.isArray(config.style.postcss.plugins)) {
|
116
|
-
config.style.postcss.plugins.push(
|
161
|
+
config.style.postcss.plugins.push(
|
162
|
+
require("tailwindcss")(tailwindConfig)
|
163
|
+
);
|
117
164
|
} else {
|
118
|
-
config.style.postcss.plugins = [
|
165
|
+
config.style.postcss.plugins = [
|
166
|
+
require("tailwindcss")(tailwindConfig)
|
167
|
+
];
|
119
168
|
}
|
120
169
|
return config;
|
121
170
|
}
|
122
171
|
};
|
123
|
-
}
|
124
|
-
})
|
172
|
+
})
|
173
|
+
});
|
174
|
+
export {
|
175
|
+
cli_default as default,
|
176
|
+
getRandomTwConfigFileName
|
177
|
+
};
|
@@ -1,27 +1,36 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
6
|
+
var __spreadValues = (a, b) => {
|
7
|
+
for (var prop in b || (b = {}))
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
10
|
+
if (__getOwnPropSymbols)
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
12
|
+
if (__propIsEnum.call(b, prop))
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
14
|
+
}
|
15
|
+
return a;
|
16
|
+
};
|
17
|
+
import {
|
18
|
+
lazyImport,
|
19
|
+
PLUGIN_SCHEMAS,
|
20
|
+
createRuntimeExportsUtils
|
21
|
+
} from "@modern-js/utils";
|
22
|
+
var cli_default = ({ pluginName } = { pluginName: "@modern-js/plugin-tailwindcss" }) => ({
|
23
|
+
name: "@modern-js/plugin-design-token",
|
11
24
|
setup(api) {
|
12
25
|
let pluginsExportsUtils;
|
13
|
-
const resolveConfig = lazyImport(
|
14
|
-
const PLUGIN_IDENTIFIER =
|
15
|
-
const getDesignTokens = designSystem => {
|
26
|
+
const resolveConfig = lazyImport("tailwindcss/resolveConfig", require);
|
27
|
+
const PLUGIN_IDENTIFIER = "designToken";
|
28
|
+
const getDesignTokens = (designSystem) => {
|
16
29
|
const tailwindcssConfig = {};
|
17
|
-
tailwindcssConfig.theme = designSystem ?
|
18
|
-
|
19
|
-
// not use default design token when designToken.defaultTheme is false or theme is false
|
30
|
+
tailwindcssConfig.theme = designSystem ? __spreadValues({}, designSystem) : {};
|
20
31
|
if (!designSystem) {
|
21
32
|
tailwindcssConfig.presets = [];
|
22
33
|
}
|
23
|
-
|
24
|
-
// when only designSystem exist, need remove supportStyledComponents
|
25
34
|
if (designSystem) {
|
26
35
|
delete tailwindcssConfig.theme.supportStyledComponents;
|
27
36
|
}
|
@@ -30,35 +39,32 @@ export default (({
|
|
30
39
|
return {
|
31
40
|
config() {
|
32
41
|
const appContext = api.useAppContext();
|
33
|
-
pluginsExportsUtils = createRuntimeExportsUtils(
|
42
|
+
pluginsExportsUtils = createRuntimeExportsUtils(
|
43
|
+
appContext.internalDirectory,
|
44
|
+
"plugins"
|
45
|
+
);
|
34
46
|
return {
|
35
47
|
source: {
|
36
48
|
alias: {
|
37
|
-
|
49
|
+
"@modern-js/runtime/plugins": pluginsExportsUtils.getPath()
|
38
50
|
}
|
39
51
|
},
|
40
|
-
tools: {
|
41
|
-
// TODO: support less、scss、css vars
|
42
|
-
// less: https://github.com/modern-js-dev/modern.js/pull/398/files#diff-f77c749e403fbf1fb676d5687bef3d7138a230331c849298d8afaff9b6afbc3dR166
|
43
|
-
// sass: https://github.com/modern-js-dev/modern.js/pull/398/files#diff-f77c749e403fbf1fb676d5687bef3d7138a230331c849298d8afaff9b6afbc3dR229
|
44
|
-
// postcss: https://github.com/modern-js-dev/modern.js/pull/398/files#diff-f77c749e403fbf1fb676d5687bef3d7138a230331c849298d8afaff9b6afbc3dR281
|
45
|
-
}
|
52
|
+
tools: {}
|
46
53
|
};
|
47
54
|
},
|
48
|
-
modifyEntryImports({
|
49
|
-
|
50
|
-
imports
|
51
|
-
}) {
|
52
|
-
var _userConfig$source$de, _userConfig$source;
|
55
|
+
modifyEntryImports({ entrypoint, imports }) {
|
56
|
+
var _a, _b;
|
53
57
|
const userConfig = api.useResolvedConfigContext();
|
54
|
-
const designSystem = (
|
55
|
-
if (typeof designSystem ===
|
58
|
+
const designSystem = (_b = (_a = userConfig.source) == null ? void 0 : _a.designSystem) != null ? _b : {};
|
59
|
+
if (typeof designSystem === "object" && designSystem.supportStyledComponents) {
|
56
60
|
const designTokens = getDesignTokens(userConfig.source.designSystem);
|
57
61
|
imports.push({
|
58
|
-
value:
|
59
|
-
specifiers: [
|
60
|
-
|
61
|
-
|
62
|
+
value: "@modern-js/runtime/plugins",
|
63
|
+
specifiers: [
|
64
|
+
{
|
65
|
+
imported: PLUGIN_IDENTIFIER
|
66
|
+
}
|
67
|
+
],
|
62
68
|
initialize: `
|
63
69
|
const designTokens = ${JSON.stringify(designTokens)};
|
64
70
|
`
|
@@ -69,22 +75,18 @@ export default (({
|
|
69
75
|
imports
|
70
76
|
};
|
71
77
|
},
|
72
|
-
modifyEntryRuntimePlugins({
|
73
|
-
|
74
|
-
plugins
|
75
|
-
}) {
|
76
|
-
var _userConfig$source$de2, _userConfig$source2;
|
78
|
+
modifyEntryRuntimePlugins({ entrypoint, plugins }) {
|
79
|
+
var _a, _b;
|
77
80
|
const userConfig = api.useResolvedConfigContext();
|
78
|
-
const designSystem = (
|
81
|
+
const designSystem = (_b = (_a = userConfig.source) == null ? void 0 : _a.designSystem) != null ? _b : {};
|
79
82
|
let useSCThemeProvider = true;
|
80
83
|
if (designSystem) {
|
81
|
-
|
82
|
-
useSCThemeProvider = (designSystem === null || designSystem === void 0 ? void 0 : designSystem.supportStyledComponents) || false;
|
84
|
+
useSCThemeProvider = (designSystem == null ? void 0 : designSystem.supportStyledComponents) || false;
|
83
85
|
}
|
84
|
-
if (typeof designSystem ===
|
86
|
+
if (typeof designSystem === "object" && designSystem.supportStyledComponents) {
|
85
87
|
plugins.push({
|
86
88
|
name: PLUGIN_IDENTIFIER,
|
87
|
-
options: `{token: designTokens, useStyledComponentsThemeProvider: ${useSCThemeProvider ?
|
89
|
+
options: `{token: designTokens, useStyledComponentsThemeProvider: ${useSCThemeProvider ? "true" : "false"}, useDesignTokenContext: false}`
|
88
90
|
});
|
89
91
|
}
|
90
92
|
return {
|
@@ -93,12 +95,16 @@ export default (({
|
|
93
95
|
};
|
94
96
|
},
|
95
97
|
validateSchema() {
|
96
|
-
|
97
|
-
return PLUGIN_SCHEMAS['@modern-js/plugin-design-token'];
|
98
|
+
return PLUGIN_SCHEMAS["@modern-js/plugin-design-token"];
|
98
99
|
},
|
99
100
|
addRuntimeExports() {
|
100
|
-
pluginsExportsUtils.addExport(
|
101
|
+
pluginsExportsUtils.addExport(
|
102
|
+
`export { default as designToken } from '${pluginName}/runtime-design-token'`
|
103
|
+
);
|
101
104
|
}
|
102
105
|
};
|
103
106
|
}
|
104
|
-
})
|
107
|
+
});
|
108
|
+
export {
|
109
|
+
cli_default as default
|
110
|
+
};
|
File without changes
|
@@ -1,15 +1,18 @@
|
|
1
|
-
|
2
|
-
cssVarsHash
|
1
|
+
var postcss_plugin_default = ({
|
2
|
+
cssVarsHash = {}
|
3
3
|
} = {}) => ({
|
4
|
-
postcssPlugin:
|
4
|
+
postcssPlugin: "postcss-replace-css-vars",
|
5
5
|
Declaration(decl) {
|
6
|
-
if (decl.value && typeof decl.value ===
|
7
|
-
decl.value = decl.value.replace(/--\S*/g, match => {
|
8
|
-
if (
|
9
|
-
return
|
6
|
+
if (decl.value && typeof decl.value === "string") {
|
7
|
+
decl.value = decl.value.replace(/--\S*/g, (match) => {
|
8
|
+
if (cssVarsHash[match]) {
|
9
|
+
return cssVarsHash[match];
|
10
10
|
}
|
11
11
|
return match;
|
12
12
|
});
|
13
13
|
}
|
14
14
|
}
|
15
|
-
})
|
15
|
+
});
|
16
|
+
export {
|
17
|
+
postcss_plugin_default as default
|
18
|
+
};
|