@modern-js/plugin-tailwindcss 2.0.0-beta.4 → 2.0.0-beta.7
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 +117 -0
- package/dist/js/modern/cli.js +43 -57
- package/dist/js/modern/tailwind.js +2 -2
- package/dist/js/modern/utils.js +24 -6
- package/dist/js/node/cli.js +52 -67
- package/dist/js/node/design-token/cli/index.js +19 -19
- package/dist/js/node/design-token/index.js +6 -4
- package/dist/js/node/design-token/postcss-plugin/index.js +5 -3
- package/dist/js/node/design-token/runtime/index.js +6 -4
- package/dist/js/node/design-token/runtime/plugin.js +22 -19
- package/dist/js/node/index.js +5 -3
- package/dist/js/node/tailwind.js +9 -5
- package/dist/js/node/types.js +15 -0
- package/dist/js/node/utils.js +37 -12
- package/dist/js/treeshaking/cli.js +40 -54
- package/dist/js/treeshaking/tailwind.js +5 -3
- package/dist/js/treeshaking/utils.js +29 -10
- package/dist/types/tailwind.d.ts +1 -1
- package/dist/types/utils.d.ts +3 -1
- package/package.json +12 -13
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,122 @@
|
|
1
1
|
# @modern-js/plugin-tailwindcss
|
2
2
|
|
3
|
+
## 2.0.0-beta.7
|
4
|
+
|
5
|
+
### Major Changes
|
6
|
+
|
7
|
+
- dda38c9c3e: chore: v2
|
8
|
+
|
9
|
+
### Patch Changes
|
10
|
+
|
11
|
+
- Updated dependencies [c9e800d39a]
|
12
|
+
- Updated dependencies [edd1cfb1af]
|
13
|
+
- Updated dependencies [6bda14ed71]
|
14
|
+
- Updated dependencies [dda38c9c3e]
|
15
|
+
- Updated dependencies [8b8e1bb571]
|
16
|
+
- Updated dependencies [bbe4c4ab64]
|
17
|
+
- @modern-js/runtime@2.0.0-beta.7
|
18
|
+
- @modern-js/utils@2.0.0-beta.7
|
19
|
+
|
20
|
+
## 2.0.0-beta.6
|
21
|
+
|
22
|
+
### Major Changes
|
23
|
+
|
24
|
+
- dda38c9c3e: chore: v2
|
25
|
+
|
26
|
+
### Minor Changes
|
27
|
+
|
28
|
+
- 92f0eade39: feat:
|
29
|
+
|
30
|
+
1. add style config and add new hook
|
31
|
+
2. add dts alias logic
|
32
|
+
3. add copy logic
|
33
|
+
4. add log logic
|
34
|
+
5. add skipDeps config
|
35
|
+
|
36
|
+
feat:
|
37
|
+
|
38
|
+
1. 添加样式配置以及新的 hook
|
39
|
+
2. 添加 dts 别名处理
|
40
|
+
3. 添加 copy 逻辑
|
41
|
+
4. 添加日志逻辑
|
42
|
+
5. 添加 skipDeps 配置
|
43
|
+
|
44
|
+
- 92f0eade39: feat:
|
45
|
+
|
46
|
+
1. core: 增加 test 函数
|
47
|
+
2. module plugins: 增加 `babel`, `mainField`, `target` 插件
|
48
|
+
3. storybook: 修改部分逻辑并且增加 tspath webpack 插件
|
49
|
+
4. 增加 designSystem 配置
|
50
|
+
|
51
|
+
feat:
|
52
|
+
|
53
|
+
1. core: add test method
|
54
|
+
2. module plugins: add `babel`, `mainField`, `target` plugin
|
55
|
+
3. storybook: change some logic and add tspath webpack plugin
|
56
|
+
4. add `designSystem` config
|
57
|
+
|
58
|
+
### Patch Changes
|
59
|
+
|
60
|
+
- d6546ad916: add buildConfig style in module-tools and remove tools
|
61
|
+
在 module-tools 里新增 buildConfig style 并删除 tools
|
62
|
+
- 67472ca1cc: fix: move babel-plugin-marcos to plugin-tailwindcss
|
63
|
+
|
64
|
+
fix: 将 babel-plugin-marcos 依赖移动到 plugin-tailwindcss 中
|
65
|
+
|
66
|
+
- Updated dependencies [2344eb26ed]
|
67
|
+
- Updated dependencies [a11fcf8b50]
|
68
|
+
- Updated dependencies [a93159440e]
|
69
|
+
- Updated dependencies [e7ce0636d1]
|
70
|
+
- Updated dependencies [b18fa8f3ed]
|
71
|
+
- Updated dependencies [7879e8f711]
|
72
|
+
- Updated dependencies [50d4675e5b]
|
73
|
+
- Updated dependencies [c9e800d39a]
|
74
|
+
- Updated dependencies [6604f1b8b3]
|
75
|
+
- Updated dependencies [6aca875011]
|
76
|
+
- Updated dependencies [fda836fe8a]
|
77
|
+
- Updated dependencies [d6bc321747]
|
78
|
+
- Updated dependencies [3e57f2bd58]
|
79
|
+
- Updated dependencies [2e6031955e]
|
80
|
+
- Updated dependencies [c5798d284f]
|
81
|
+
- Updated dependencies [fbf5eed5aa]
|
82
|
+
- Updated dependencies [a2509bfbdb]
|
83
|
+
- Updated dependencies [a7c68832b3]
|
84
|
+
- Updated dependencies [425e57092d]
|
85
|
+
- Updated dependencies [e4357f1856]
|
86
|
+
- Updated dependencies [7b7d12cf8f]
|
87
|
+
- Updated dependencies [4369648ae2]
|
88
|
+
- Updated dependencies [7efeed4]
|
89
|
+
- Updated dependencies [92f0eade39]
|
90
|
+
- Updated dependencies [df7ee2d]
|
91
|
+
- Updated dependencies [92c0994468]
|
92
|
+
- Updated dependencies [2cc2eb35ba]
|
93
|
+
- Updated dependencies [edd1cfb1af]
|
94
|
+
- Updated dependencies [cc971eabfc]
|
95
|
+
- Updated dependencies [5b9049f2e9]
|
96
|
+
- Updated dependencies [6bda14ed71]
|
97
|
+
- Updated dependencies [92004d1906]
|
98
|
+
- Updated dependencies [b8bbe036c7]
|
99
|
+
- Updated dependencies [40ed5874c6]
|
100
|
+
- Updated dependencies [60d5378632]
|
101
|
+
- Updated dependencies [d5a31df781]
|
102
|
+
- Updated dependencies [dda38c9c3e]
|
103
|
+
- Updated dependencies [8b8e1bb571]
|
104
|
+
- Updated dependencies [3bbea92b2a]
|
105
|
+
- Updated dependencies [21d7521]
|
106
|
+
- Updated dependencies [9144c21d27]
|
107
|
+
- Updated dependencies [b710adb843]
|
108
|
+
- Updated dependencies [18aaf42249]
|
109
|
+
- Updated dependencies [34702d5d47]
|
110
|
+
- Updated dependencies [fcace5b5b9]
|
111
|
+
- Updated dependencies [ea7cf06257]
|
112
|
+
- Updated dependencies [bbe4c4ab64]
|
113
|
+
- Updated dependencies [e4558a0bc4]
|
114
|
+
- Updated dependencies [abf3421a75]
|
115
|
+
- Updated dependencies [543be9558e]
|
116
|
+
- Updated dependencies [14b712da84]
|
117
|
+
- @modern-js/runtime@2.0.0-beta.6
|
118
|
+
- @modern-js/utils@2.0.0-beta.6
|
119
|
+
|
3
120
|
## 2.0.0-beta.4
|
4
121
|
|
5
122
|
### Major Changes
|
package/dist/js/modern/cli.js
CHANGED
@@ -29,7 +29,12 @@ import {
|
|
29
29
|
} from "@modern-js/utils";
|
30
30
|
import DesignTokenPlugin from "./design-token/cli";
|
31
31
|
import { getTailwindConfig } from "./tailwind";
|
32
|
-
import {
|
32
|
+
import {
|
33
|
+
template,
|
34
|
+
checkTwinMacroExist,
|
35
|
+
getTailwindPath,
|
36
|
+
getTailwindVersion
|
37
|
+
} from "./utils";
|
33
38
|
const supportCssInJsLibrary = "styled-components";
|
34
39
|
const getRandomTwConfigFileName = (internalDirectory) => {
|
35
40
|
return slash(
|
@@ -51,10 +56,22 @@ var cli_default = ({ pluginName } = {
|
|
51
56
|
setup: (api) => __async(void 0, null, function* () {
|
52
57
|
const { appDirectory, internalDirectory } = api.useAppContext();
|
53
58
|
let internalTwConfigPath = "";
|
54
|
-
const
|
59
|
+
const haveTwinMacro = yield checkTwinMacroExist(appDirectory);
|
60
|
+
const tailwindPath = getTailwindPath(appDirectory);
|
61
|
+
const tailwindVersion = getTailwindVersion(appDirectory);
|
62
|
+
const defaultContent = [
|
63
|
+
"./config/html/**/*.html",
|
64
|
+
"./config/html/**/*.ejs",
|
65
|
+
"./config/html/**/*.hbs",
|
66
|
+
"./src/**/*.js",
|
67
|
+
"./src/**/*.jsx",
|
68
|
+
"./src/**/*.ts",
|
69
|
+
"./src/**/*.tsx",
|
70
|
+
"./storybook/**/*"
|
71
|
+
];
|
55
72
|
return {
|
56
73
|
prepare() {
|
57
|
-
if (
|
74
|
+
if (!haveTwinMacro) {
|
58
75
|
return;
|
59
76
|
}
|
60
77
|
internalTwConfigPath = getRandomTwConfigFileName(internalDirectory);
|
@@ -82,89 +99,58 @@ var cli_default = ({ pluginName } = {
|
|
82
99
|
var _a, _b;
|
83
100
|
const modernConfig = api.useResolvedConfigContext();
|
84
101
|
const tailwindConfig = getTailwindConfig(
|
102
|
+
tailwindVersion,
|
85
103
|
(_a = modernConfig == null ? void 0 : modernConfig.tools) == null ? void 0 : _a.tailwindcss,
|
86
104
|
(_b = modernConfig == null ? void 0 : modernConfig.source) == null ? void 0 : _b.designSystem,
|
87
105
|
{
|
88
106
|
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
|
-
]
|
107
|
+
content: defaultContent
|
103
108
|
}
|
104
109
|
}
|
105
110
|
);
|
111
|
+
const tailwindPlugin = require(tailwindPath)(tailwindConfig);
|
106
112
|
if (Array.isArray(config.postcssOptions.plugins)) {
|
107
|
-
config.postcssOptions.plugins.push(
|
108
|
-
require("tailwindcss")(tailwindConfig)
|
109
|
-
);
|
113
|
+
config.postcssOptions.plugins.push(tailwindPlugin);
|
110
114
|
} else {
|
111
|
-
config.postcssOptions.plugins = [
|
112
|
-
require("tailwindcss")(tailwindConfig)
|
113
|
-
];
|
115
|
+
config.postcssOptions.plugins = [tailwindPlugin];
|
114
116
|
}
|
115
117
|
},
|
116
118
|
babel(_, { addPlugins }) {
|
117
|
-
if (
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
config: internalTwConfigPath
|
119
|
+
if (haveTwinMacro) {
|
120
|
+
addPlugins([
|
121
|
+
[
|
122
|
+
require.resolve("babel-plugin-macros"),
|
123
|
+
{
|
124
|
+
twin: {
|
125
|
+
preset: supportCssInJsLibrary,
|
126
|
+
config: internalTwConfigPath
|
127
|
+
}
|
127
128
|
}
|
128
|
-
|
129
|
-
]
|
130
|
-
|
129
|
+
]
|
130
|
+
]);
|
131
|
+
}
|
131
132
|
}
|
132
133
|
}
|
133
134
|
};
|
134
135
|
},
|
135
|
-
beforeBuildTask(
|
136
|
+
beforeBuildTask(config) {
|
136
137
|
const modernConfig = api.useResolvedConfigContext();
|
137
138
|
const { designSystem } = modernConfig;
|
138
139
|
const tailwindConfig = getTailwindConfig(
|
140
|
+
tailwindVersion,
|
139
141
|
config.style.tailwindCss,
|
140
142
|
designSystem,
|
141
143
|
{
|
142
144
|
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
|
-
]
|
145
|
+
content: defaultContent
|
157
146
|
}
|
158
147
|
}
|
159
148
|
);
|
149
|
+
const tailwindPlugin = require(tailwindPath)(tailwindConfig);
|
160
150
|
if (Array.isArray(config.style.postcss.plugins)) {
|
161
|
-
config.style.postcss.plugins.push(
|
162
|
-
require("tailwindcss")(tailwindConfig)
|
163
|
-
);
|
151
|
+
config.style.postcss.plugins.push(tailwindPlugin);
|
164
152
|
} else {
|
165
|
-
config.style.postcss.plugins = [
|
166
|
-
require("tailwindcss")(tailwindConfig)
|
167
|
-
];
|
153
|
+
config.style.postcss.plugins = [tailwindPlugin];
|
168
154
|
}
|
169
155
|
return config;
|
170
156
|
}
|
@@ -13,7 +13,7 @@ const getPureDesignSystemConfig = (designSystemConfig) => {
|
|
13
13
|
delete pureDesignSystemConfig.supportStyledComponents;
|
14
14
|
return pureDesignSystemConfig;
|
15
15
|
};
|
16
|
-
const getTailwindConfig = (tailwindcss, designSystem, option = {}) => {
|
16
|
+
const getTailwindConfig = (tailwindVersion, tailwindcss, designSystem, option = {}) => {
|
17
17
|
const purgeConfig = merge(
|
18
18
|
{
|
19
19
|
enabled: process.env.NODE_ENV === "production",
|
@@ -22,7 +22,7 @@ const getTailwindConfig = (tailwindcss, designSystem, option = {}) => {
|
|
22
22
|
},
|
23
23
|
option.pureConfig || {}
|
24
24
|
);
|
25
|
-
const defaultTailwindConfig = {
|
25
|
+
const defaultTailwindConfig = tailwindVersion === "3" ? { content: purgeConfig.content } : {
|
26
26
|
purge: purgeConfig
|
27
27
|
};
|
28
28
|
const tailwindConfig = applyOptionsChain(
|
package/dist/js/modern/utils.js
CHANGED
@@ -40,17 +40,35 @@ module.exports = {
|
|
40
40
|
...tailwindcss,
|
41
41
|
};
|
42
42
|
`;
|
43
|
-
const
|
43
|
+
const checkTwinMacroExist = (appDirectory) => __async(void 0, null, function* () {
|
44
44
|
const depName = "twin.macro";
|
45
45
|
const packageJson = (yield fs.readJSON(path.join(appDirectory, "package.json"), {
|
46
46
|
throws: false
|
47
47
|
})) || {};
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
return true;
|
48
|
+
return Boolean(
|
49
|
+
typeof packageJson.dependencies === "object" && packageJson.dependencies[depName] || typeof packageJson.devDependencies === "object" && packageJson.devDependencies[depName]
|
50
|
+
);
|
52
51
|
});
|
52
|
+
function getTailwindPath(appDirectory) {
|
53
|
+
try {
|
54
|
+
return require.resolve("tailwindcss", { paths: [appDirectory, __dirname] });
|
55
|
+
} catch (err) {
|
56
|
+
return "tailwindcss";
|
57
|
+
}
|
58
|
+
}
|
59
|
+
function getTailwindVersion(appDirectory) {
|
60
|
+
try {
|
61
|
+
const packageJsonPath = require.resolve("tailwindcss/package.json", {
|
62
|
+
paths: [appDirectory, __dirname]
|
63
|
+
});
|
64
|
+
return require(packageJsonPath).version.split(".")[0];
|
65
|
+
} catch (err) {
|
66
|
+
return "3";
|
67
|
+
}
|
68
|
+
}
|
53
69
|
export {
|
54
|
-
|
70
|
+
checkTwinMacroExist,
|
71
|
+
getTailwindPath,
|
72
|
+
getTailwindVersion,
|
55
73
|
template
|
56
74
|
};
|
package/dist/js/node/cli.js
CHANGED
@@ -21,17 +21,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
21
21
|
mod
|
22
22
|
));
|
23
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
24
|
-
var stdin_exports = {};
|
25
|
-
__export(stdin_exports, {
|
26
|
-
default: () => cli_default,
|
27
|
-
getRandomTwConfigFileName: () => getRandomTwConfigFileName
|
28
|
-
});
|
29
|
-
module.exports = __toCommonJS(stdin_exports);
|
30
|
-
var import_path = __toESM(require("path"));
|
31
|
-
var import_utils = require("@modern-js/utils");
|
32
|
-
var import_cli = __toESM(require("./design-token/cli"));
|
33
|
-
var import_tailwind = require("./tailwind");
|
34
|
-
var import_utils2 = require("./utils");
|
35
24
|
var __async = (__this, __arguments, generator) => {
|
36
25
|
return new Promise((resolve, reject) => {
|
37
26
|
var fulfilled = (value) => {
|
@@ -52,6 +41,17 @@ var __async = (__this, __arguments, generator) => {
|
|
52
41
|
step((generator = generator.apply(__this, __arguments)).next());
|
53
42
|
});
|
54
43
|
};
|
44
|
+
var cli_exports = {};
|
45
|
+
__export(cli_exports, {
|
46
|
+
default: () => cli_default,
|
47
|
+
getRandomTwConfigFileName: () => getRandomTwConfigFileName
|
48
|
+
});
|
49
|
+
module.exports = __toCommonJS(cli_exports);
|
50
|
+
var import_path = __toESM(require("path"));
|
51
|
+
var import_utils = require("@modern-js/utils");
|
52
|
+
var import_cli = __toESM(require("./design-token/cli"));
|
53
|
+
var import_tailwind = require("./tailwind");
|
54
|
+
var import_utils2 = require("./utils");
|
55
55
|
const supportCssInJsLibrary = "styled-components";
|
56
56
|
const getRandomTwConfigFileName = (internalDirectory) => {
|
57
57
|
return (0, import_utils.slash)(
|
@@ -73,10 +73,22 @@ var cli_default = ({ pluginName } = {
|
|
73
73
|
setup: (api) => __async(void 0, null, function* () {
|
74
74
|
const { appDirectory, internalDirectory } = api.useAppContext();
|
75
75
|
let internalTwConfigPath = "";
|
76
|
-
const
|
76
|
+
const haveTwinMacro = yield (0, import_utils2.checkTwinMacroExist)(appDirectory);
|
77
|
+
const tailwindPath = (0, import_utils2.getTailwindPath)(appDirectory);
|
78
|
+
const tailwindVersion = (0, import_utils2.getTailwindVersion)(appDirectory);
|
79
|
+
const defaultContent = [
|
80
|
+
"./config/html/**/*.html",
|
81
|
+
"./config/html/**/*.ejs",
|
82
|
+
"./config/html/**/*.hbs",
|
83
|
+
"./src/**/*.js",
|
84
|
+
"./src/**/*.jsx",
|
85
|
+
"./src/**/*.ts",
|
86
|
+
"./src/**/*.tsx",
|
87
|
+
"./storybook/**/*"
|
88
|
+
];
|
77
89
|
return {
|
78
90
|
prepare() {
|
79
|
-
if (
|
91
|
+
if (!haveTwinMacro) {
|
80
92
|
return;
|
81
93
|
}
|
82
94
|
internalTwConfigPath = getRandomTwConfigFileName(internalDirectory);
|
@@ -104,92 +116,65 @@ var cli_default = ({ pluginName } = {
|
|
104
116
|
var _a, _b;
|
105
117
|
const modernConfig = api.useResolvedConfigContext();
|
106
118
|
const tailwindConfig = (0, import_tailwind.getTailwindConfig)(
|
119
|
+
tailwindVersion,
|
107
120
|
(_a = modernConfig == null ? void 0 : modernConfig.tools) == null ? void 0 : _a.tailwindcss,
|
108
121
|
(_b = modernConfig == null ? void 0 : modernConfig.source) == null ? void 0 : _b.designSystem,
|
109
122
|
{
|
110
123
|
pureConfig: {
|
111
|
-
content:
|
112
|
-
"./config/html/**/*.html",
|
113
|
-
"./config/html/**/*.ejs",
|
114
|
-
"./config/html/**/*.hbs",
|
115
|
-
"./src/**/*.js",
|
116
|
-
"./src/**/*.jsx",
|
117
|
-
"./src/**/*.ts",
|
118
|
-
"./src/**/*.tsx",
|
119
|
-
"./storybook/**/*",
|
120
|
-
"./styles/**/*.less",
|
121
|
-
"./styles/**/*.css",
|
122
|
-
"./styles/**/*.sass",
|
123
|
-
"./styles/**/*.scss"
|
124
|
-
]
|
124
|
+
content: defaultContent
|
125
125
|
}
|
126
126
|
}
|
127
127
|
);
|
128
|
+
const tailwindPlugin = require(tailwindPath)(tailwindConfig);
|
128
129
|
if (Array.isArray(config.postcssOptions.plugins)) {
|
129
|
-
config.postcssOptions.plugins.push(
|
130
|
-
require("tailwindcss")(tailwindConfig)
|
131
|
-
);
|
130
|
+
config.postcssOptions.plugins.push(tailwindPlugin);
|
132
131
|
} else {
|
133
|
-
config.postcssOptions.plugins = [
|
134
|
-
require("tailwindcss")(tailwindConfig)
|
135
|
-
];
|
132
|
+
config.postcssOptions.plugins = [tailwindPlugin];
|
136
133
|
}
|
137
134
|
},
|
138
135
|
babel(_, { addPlugins }) {
|
139
|
-
if (
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
config: internalTwConfigPath
|
136
|
+
if (haveTwinMacro) {
|
137
|
+
addPlugins([
|
138
|
+
[
|
139
|
+
require.resolve("babel-plugin-macros"),
|
140
|
+
{
|
141
|
+
twin: {
|
142
|
+
preset: supportCssInJsLibrary,
|
143
|
+
config: internalTwConfigPath
|
144
|
+
}
|
149
145
|
}
|
150
|
-
|
151
|
-
]
|
152
|
-
|
146
|
+
]
|
147
|
+
]);
|
148
|
+
}
|
153
149
|
}
|
154
150
|
}
|
155
151
|
};
|
156
152
|
},
|
157
|
-
beforeBuildTask(
|
153
|
+
beforeBuildTask(config) {
|
158
154
|
const modernConfig = api.useResolvedConfigContext();
|
159
155
|
const { designSystem } = modernConfig;
|
160
156
|
const tailwindConfig = (0, import_tailwind.getTailwindConfig)(
|
157
|
+
tailwindVersion,
|
161
158
|
config.style.tailwindCss,
|
162
159
|
designSystem,
|
163
160
|
{
|
164
161
|
pureConfig: {
|
165
|
-
content:
|
166
|
-
"./config/html/**/*.html",
|
167
|
-
"./config/html/**/*.ejs",
|
168
|
-
"./config/html/**/*.hbs",
|
169
|
-
"./src/**/*.js",
|
170
|
-
"./src/**/*.jsx",
|
171
|
-
"./src/**/*.ts",
|
172
|
-
"./src/**/*.tsx",
|
173
|
-
"./storybook/**/*",
|
174
|
-
"./styles/**/*.less",
|
175
|
-
"./styles/**/*.css",
|
176
|
-
"./styles/**/*.sass",
|
177
|
-
"./styles/**/*.scss"
|
178
|
-
]
|
162
|
+
content: defaultContent
|
179
163
|
}
|
180
164
|
}
|
181
165
|
);
|
166
|
+
const tailwindPlugin = require(tailwindPath)(tailwindConfig);
|
182
167
|
if (Array.isArray(config.style.postcss.plugins)) {
|
183
|
-
config.style.postcss.plugins.push(
|
184
|
-
require("tailwindcss")(tailwindConfig)
|
185
|
-
);
|
168
|
+
config.style.postcss.plugins.push(tailwindPlugin);
|
186
169
|
} else {
|
187
|
-
config.style.postcss.plugins = [
|
188
|
-
require("tailwindcss")(tailwindConfig)
|
189
|
-
];
|
170
|
+
config.style.postcss.plugins = [tailwindPlugin];
|
190
171
|
}
|
191
172
|
return config;
|
192
173
|
}
|
193
174
|
};
|
194
175
|
})
|
195
176
|
});
|
177
|
+
// Annotate the CommonJS export names for ESM import in node:
|
178
|
+
0 && (module.exports = {
|
179
|
+
getRandomTwConfigFileName
|
180
|
+
});
|
@@ -1,7 +1,21 @@
|
|
1
1
|
var __defProp = Object.defineProperty;
|
2
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
4
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
8
|
+
var __spreadValues = (a, b) => {
|
9
|
+
for (var prop in b || (b = {}))
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
12
|
+
if (__getOwnPropSymbols)
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
14
|
+
if (__propIsEnum.call(b, prop))
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
16
|
+
}
|
17
|
+
return a;
|
18
|
+
};
|
5
19
|
var __export = (target, all) => {
|
6
20
|
for (var name in all)
|
7
21
|
__defProp(target, name, { get: all[name], enumerable: true });
|
@@ -15,28 +29,12 @@ var __copyProps = (to, from, except, desc) => {
|
|
15
29
|
return to;
|
16
30
|
};
|
17
31
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
18
|
-
var
|
19
|
-
__export(
|
32
|
+
var cli_exports = {};
|
33
|
+
__export(cli_exports, {
|
20
34
|
default: () => cli_default
|
21
35
|
});
|
22
|
-
module.exports = __toCommonJS(
|
36
|
+
module.exports = __toCommonJS(cli_exports);
|
23
37
|
var import_utils = require("@modern-js/utils");
|
24
|
-
var __defProp2 = Object.defineProperty;
|
25
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
26
|
-
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
27
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
28
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
29
|
-
var __spreadValues = (a, b) => {
|
30
|
-
for (var prop in b || (b = {}))
|
31
|
-
if (__hasOwnProp2.call(b, prop))
|
32
|
-
__defNormalProp(a, prop, b[prop]);
|
33
|
-
if (__getOwnPropSymbols)
|
34
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
35
|
-
if (__propIsEnum.call(b, prop))
|
36
|
-
__defNormalProp(a, prop, b[prop]);
|
37
|
-
}
|
38
|
-
return a;
|
39
|
-
};
|
40
38
|
var cli_default = ({ pluginName } = { pluginName: "@modern-js/plugin-tailwindcss" }) => ({
|
41
39
|
name: "@modern-js/plugin-design-token",
|
42
40
|
setup(api) {
|
@@ -123,3 +121,5 @@ var cli_default = ({ pluginName } = { pluginName: "@modern-js/plugin-tailwindcss
|
|
123
121
|
};
|
124
122
|
}
|
125
123
|
});
|
124
|
+
// Annotate the CommonJS export names for ESM import in node:
|
125
|
+
0 && (module.exports = {});
|
@@ -22,10 +22,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
22
22
|
mod
|
23
23
|
));
|
24
24
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
25
|
-
var
|
26
|
-
__export(
|
25
|
+
var design_token_exports = {};
|
26
|
+
__export(design_token_exports, {
|
27
27
|
default: () => import_runtime.default
|
28
28
|
});
|
29
|
-
module.exports = __toCommonJS(
|
29
|
+
module.exports = __toCommonJS(design_token_exports);
|
30
30
|
var import_runtime = __toESM(require("./runtime"));
|
31
|
-
__reExport(
|
31
|
+
__reExport(design_token_exports, require("./runtime"), module.exports);
|
32
|
+
// Annotate the CommonJS export names for ESM import in node:
|
33
|
+
0 && (module.exports = {});
|
@@ -15,11 +15,11 @@ var __copyProps = (to, from, except, desc) => {
|
|
15
15
|
return to;
|
16
16
|
};
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
18
|
-
var
|
19
|
-
__export(
|
18
|
+
var postcss_plugin_exports = {};
|
19
|
+
__export(postcss_plugin_exports, {
|
20
20
|
default: () => postcss_plugin_default
|
21
21
|
});
|
22
|
-
module.exports = __toCommonJS(
|
22
|
+
module.exports = __toCommonJS(postcss_plugin_exports);
|
23
23
|
var postcss_plugin_default = ({
|
24
24
|
cssVarsHash = {}
|
25
25
|
} = {}) => ({
|
@@ -35,3 +35,5 @@ var postcss_plugin_default = ({
|
|
35
35
|
}
|
36
36
|
}
|
37
37
|
});
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
39
|
+
0 && (module.exports = {});
|
@@ -22,11 +22,13 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
22
22
|
mod
|
23
23
|
));
|
24
24
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
25
|
-
var
|
26
|
-
__export(
|
25
|
+
var runtime_exports = {};
|
26
|
+
__export(runtime_exports, {
|
27
27
|
default: () => runtime_default
|
28
28
|
});
|
29
|
-
module.exports = __toCommonJS(
|
29
|
+
module.exports = __toCommonJS(runtime_exports);
|
30
30
|
var import_plugin = __toESM(require("./plugin"));
|
31
|
-
__reExport(
|
31
|
+
__reExport(runtime_exports, require("./plugin"), module.exports);
|
32
32
|
var runtime_default = import_plugin.default;
|
33
|
+
// Annotate the CommonJS export names for ESM import in node:
|
34
|
+
0 && (module.exports = {});
|
@@ -2,8 +2,22 @@ var __create = Object.create;
|
|
2
2
|
var __defProp = Object.defineProperty;
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
5
6
|
var __getProtoOf = Object.getPrototypeOf;
|
6
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
9
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
10
|
+
var __spreadValues = (a, b) => {
|
11
|
+
for (var prop in b || (b = {}))
|
12
|
+
if (__hasOwnProp.call(b, prop))
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
14
|
+
if (__getOwnPropSymbols)
|
15
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
16
|
+
if (__propIsEnum.call(b, prop))
|
17
|
+
__defNormalProp(a, prop, b[prop]);
|
18
|
+
}
|
19
|
+
return a;
|
20
|
+
};
|
7
21
|
var __export = (target, all) => {
|
8
22
|
for (var name in all)
|
9
23
|
__defProp(target, name, { get: all[name], enumerable: true });
|
@@ -21,32 +35,16 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
21
35
|
mod
|
22
36
|
));
|
23
37
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
24
|
-
var
|
25
|
-
__export(
|
38
|
+
var plugin_exports = {};
|
39
|
+
__export(plugin_exports, {
|
26
40
|
DesignTokenContext: () => DesignTokenContext,
|
27
41
|
default: () => plugin_default,
|
28
42
|
useDesignTokens: () => useDesignTokens
|
29
43
|
});
|
30
|
-
module.exports = __toCommonJS(
|
44
|
+
module.exports = __toCommonJS(plugin_exports);
|
31
45
|
var import_jsx_runtime = require("react/jsx-runtime");
|
32
46
|
var import_hoist_non_react_statics = __toESM(require("hoist-non-react-statics"));
|
33
47
|
var import_react = __toESM(require("react"));
|
34
|
-
var __defProp2 = Object.defineProperty;
|
35
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
36
|
-
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
37
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
38
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
39
|
-
var __spreadValues = (a, b) => {
|
40
|
-
for (var prop in b || (b = {}))
|
41
|
-
if (__hasOwnProp2.call(b, prop))
|
42
|
-
__defNormalProp(a, prop, b[prop]);
|
43
|
-
if (__getOwnPropSymbols)
|
44
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
45
|
-
if (__propIsEnum.call(b, prop))
|
46
|
-
__defNormalProp(a, prop, b[prop]);
|
47
|
-
}
|
48
|
-
return a;
|
49
|
-
};
|
50
48
|
const DesignTokenContext = import_react.default.createContext({});
|
51
49
|
const useDesignTokens = () => (0, import_react.useContext)(DesignTokenContext);
|
52
50
|
var plugin_default = (options = {}) => ({
|
@@ -89,3 +87,8 @@ var plugin_default = (options = {}) => ({
|
|
89
87
|
}
|
90
88
|
})
|
91
89
|
});
|
90
|
+
// Annotate the CommonJS export names for ESM import in node:
|
91
|
+
0 && (module.exports = {
|
92
|
+
DesignTokenContext,
|
93
|
+
useDesignTokens
|
94
|
+
});
|
package/dist/js/node/index.js
CHANGED
@@ -21,9 +21,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
21
21
|
mod
|
22
22
|
));
|
23
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
24
|
-
var
|
25
|
-
__export(
|
24
|
+
var src_exports = {};
|
25
|
+
__export(src_exports, {
|
26
26
|
default: () => import_cli.default
|
27
27
|
});
|
28
|
-
module.exports = __toCommonJS(
|
28
|
+
module.exports = __toCommonJS(src_exports);
|
29
29
|
var import_cli = __toESM(require("./cli"));
|
30
|
+
// Annotate the CommonJS export names for ESM import in node:
|
31
|
+
0 && (module.exports = {});
|
package/dist/js/node/tailwind.js
CHANGED
@@ -15,11 +15,11 @@ var __copyProps = (to, from, except, desc) => {
|
|
15
15
|
return to;
|
16
16
|
};
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
18
|
-
var
|
19
|
-
__export(
|
18
|
+
var tailwind_exports = {};
|
19
|
+
__export(tailwind_exports, {
|
20
20
|
getTailwindConfig: () => getTailwindConfig
|
21
21
|
});
|
22
|
-
module.exports = __toCommonJS(
|
22
|
+
module.exports = __toCommonJS(tailwind_exports);
|
23
23
|
var import_utils = require("@modern-js/utils");
|
24
24
|
var import_lodash = require("@modern-js/utils/lodash");
|
25
25
|
const checkIfExistNotAllowKeys = (tailwindConfig) => {
|
@@ -35,7 +35,7 @@ const getPureDesignSystemConfig = (designSystemConfig) => {
|
|
35
35
|
delete pureDesignSystemConfig.supportStyledComponents;
|
36
36
|
return pureDesignSystemConfig;
|
37
37
|
};
|
38
|
-
const getTailwindConfig = (tailwindcss, designSystem, option = {}) => {
|
38
|
+
const getTailwindConfig = (tailwindVersion, tailwindcss, designSystem, option = {}) => {
|
39
39
|
const purgeConfig = (0, import_lodash.merge)(
|
40
40
|
{
|
41
41
|
enabled: process.env.NODE_ENV === "production",
|
@@ -44,7 +44,7 @@ const getTailwindConfig = (tailwindcss, designSystem, option = {}) => {
|
|
44
44
|
},
|
45
45
|
option.pureConfig || {}
|
46
46
|
);
|
47
|
-
const defaultTailwindConfig = {
|
47
|
+
const defaultTailwindConfig = tailwindVersion === "3" ? { content: purgeConfig.content } : {
|
48
48
|
purge: purgeConfig
|
49
49
|
};
|
50
50
|
const tailwindConfig = (0, import_utils.applyOptionsChain)(
|
@@ -62,3 +62,7 @@ const getTailwindConfig = (tailwindcss, designSystem, option = {}) => {
|
|
62
62
|
tailwindConfig.theme = designSystemConfig || {};
|
63
63
|
return tailwindConfig;
|
64
64
|
};
|
65
|
+
// Annotate the CommonJS export names for ESM import in node:
|
66
|
+
0 && (module.exports = {
|
67
|
+
getTailwindConfig
|
68
|
+
});
|
package/dist/js/node/types.js
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
7
|
+
for (let key of __getOwnPropNames(from))
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
10
|
+
}
|
11
|
+
return to;
|
12
|
+
};
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
14
|
+
var types_exports = {};
|
15
|
+
module.exports = __toCommonJS(types_exports);
|
package/dist/js/node/utils.js
CHANGED
@@ -21,14 +21,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
21
21
|
mod
|
22
22
|
));
|
23
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
24
|
-
var stdin_exports = {};
|
25
|
-
__export(stdin_exports, {
|
26
|
-
checkTwinMacroNotExist: () => checkTwinMacroNotExist,
|
27
|
-
template: () => template
|
28
|
-
});
|
29
|
-
module.exports = __toCommonJS(stdin_exports);
|
30
|
-
var import_path = __toESM(require("path"));
|
31
|
-
var import_utils = require("@modern-js/utils");
|
32
24
|
var __async = (__this, __arguments, generator) => {
|
33
25
|
return new Promise((resolve, reject) => {
|
34
26
|
var fulfilled = (value) => {
|
@@ -49,6 +41,16 @@ var __async = (__this, __arguments, generator) => {
|
|
49
41
|
step((generator = generator.apply(__this, __arguments)).next());
|
50
42
|
});
|
51
43
|
};
|
44
|
+
var utils_exports = {};
|
45
|
+
__export(utils_exports, {
|
46
|
+
checkTwinMacroExist: () => checkTwinMacroExist,
|
47
|
+
getTailwindPath: () => getTailwindPath,
|
48
|
+
getTailwindVersion: () => getTailwindVersion,
|
49
|
+
template: () => template
|
50
|
+
});
|
51
|
+
module.exports = __toCommonJS(utils_exports);
|
52
|
+
var import_path = __toESM(require("path"));
|
53
|
+
var import_utils = require("@modern-js/utils");
|
52
54
|
const template = (configPath) => `
|
53
55
|
function _interopRequireDefault(obj) {
|
54
56
|
return obj && obj.__esModule ? obj : { default: obj };
|
@@ -69,13 +71,36 @@ module.exports = {
|
|
69
71
|
...tailwindcss,
|
70
72
|
};
|
71
73
|
`;
|
72
|
-
const
|
74
|
+
const checkTwinMacroExist = (appDirectory) => __async(void 0, null, function* () {
|
73
75
|
const depName = "twin.macro";
|
74
76
|
const packageJson = (yield import_utils.fs.readJSON(import_path.default.join(appDirectory, "package.json"), {
|
75
77
|
throws: false
|
76
78
|
})) || {};
|
77
|
-
|
78
|
-
|
79
|
+
return Boolean(
|
80
|
+
typeof packageJson.dependencies === "object" && packageJson.dependencies[depName] || typeof packageJson.devDependencies === "object" && packageJson.devDependencies[depName]
|
81
|
+
);
|
82
|
+
});
|
83
|
+
function getTailwindPath(appDirectory) {
|
84
|
+
try {
|
85
|
+
return require.resolve("tailwindcss", { paths: [appDirectory, __dirname] });
|
86
|
+
} catch (err) {
|
87
|
+
return "tailwindcss";
|
79
88
|
}
|
80
|
-
|
89
|
+
}
|
90
|
+
function getTailwindVersion(appDirectory) {
|
91
|
+
try {
|
92
|
+
const packageJsonPath = require.resolve("tailwindcss/package.json", {
|
93
|
+
paths: [appDirectory, __dirname]
|
94
|
+
});
|
95
|
+
return require(packageJsonPath).version.split(".")[0];
|
96
|
+
} catch (err) {
|
97
|
+
return "3";
|
98
|
+
}
|
99
|
+
}
|
100
|
+
// Annotate the CommonJS export names for ESM import in node:
|
101
|
+
0 && (module.exports = {
|
102
|
+
checkTwinMacroExist,
|
103
|
+
getTailwindPath,
|
104
|
+
getTailwindVersion,
|
105
|
+
template
|
81
106
|
});
|
@@ -126,7 +126,7 @@ import path from "path";
|
|
126
126
|
import { PLUGIN_SCHEMAS, fs, CONFIG_CACHE_DIR, globby, nanoid, slash } from "@modern-js/utils";
|
127
127
|
import DesignTokenPlugin from "./design-token/cli";
|
128
128
|
import { getTailwindConfig } from "./tailwind";
|
129
|
-
import { template,
|
129
|
+
import { template, checkTwinMacroExist, getTailwindPath, getTailwindVersion } from "./utils";
|
130
130
|
var supportCssInJsLibrary = "styled-components";
|
131
131
|
var getRandomTwConfigFileName = function(internalDirectory) {
|
132
132
|
return slash(path.join(internalDirectory, "tailwind.config.".concat(Date.now(), ".").concat(nanoid(), ".js")));
|
@@ -144,7 +144,7 @@ var cli_default = function() {
|
|
144
144
|
],
|
145
145
|
setup: function() {
|
146
146
|
var _ref = _asyncToGenerator(function(api) {
|
147
|
-
var ref, appDirectory, internalDirectory, internalTwConfigPath,
|
147
|
+
var ref, appDirectory, internalDirectory, internalTwConfigPath, haveTwinMacro, tailwindPath, tailwindVersion, defaultContent;
|
148
148
|
return __generator(this, function(_state) {
|
149
149
|
switch(_state.label){
|
150
150
|
case 0:
|
@@ -152,15 +152,27 @@ var cli_default = function() {
|
|
152
152
|
internalTwConfigPath = "";
|
153
153
|
return [
|
154
154
|
4,
|
155
|
-
|
155
|
+
checkTwinMacroExist(appDirectory)
|
156
156
|
];
|
157
157
|
case 1:
|
158
|
-
|
158
|
+
haveTwinMacro = _state.sent();
|
159
|
+
tailwindPath = getTailwindPath(appDirectory);
|
160
|
+
tailwindVersion = getTailwindVersion(appDirectory);
|
161
|
+
defaultContent = [
|
162
|
+
"./config/html/**/*.html",
|
163
|
+
"./config/html/**/*.ejs",
|
164
|
+
"./config/html/**/*.hbs",
|
165
|
+
"./src/**/*.js",
|
166
|
+
"./src/**/*.jsx",
|
167
|
+
"./src/**/*.ts",
|
168
|
+
"./src/**/*.tsx",
|
169
|
+
"./storybook/**/*"
|
170
|
+
];
|
159
171
|
return [
|
160
172
|
2,
|
161
173
|
{
|
162
174
|
prepare: function prepare() {
|
163
|
-
if (
|
175
|
+
if (!haveTwinMacro) {
|
164
176
|
return;
|
165
177
|
}
|
166
178
|
internalTwConfigPath = getRandomTwConfigFileName(internalDirectory);
|
@@ -181,79 +193,53 @@ var cli_default = function() {
|
|
181
193
|
postcss: function(config) {
|
182
194
|
var ref, ref1;
|
183
195
|
var modernConfig = api.useResolvedConfigContext();
|
184
|
-
var tailwindConfig = getTailwindConfig(modernConfig === null || modernConfig === void 0 ? void 0 : (ref = modernConfig.tools) === null || ref === void 0 ? void 0 : ref.tailwindcss, modernConfig === null || modernConfig === void 0 ? void 0 : (ref1 = modernConfig.source) === null || ref1 === void 0 ? void 0 : ref1.designSystem, {
|
196
|
+
var tailwindConfig = getTailwindConfig(tailwindVersion, modernConfig === null || modernConfig === void 0 ? void 0 : (ref = modernConfig.tools) === null || ref === void 0 ? void 0 : ref.tailwindcss, modernConfig === null || modernConfig === void 0 ? void 0 : (ref1 = modernConfig.source) === null || ref1 === void 0 ? void 0 : ref1.designSystem, {
|
185
197
|
pureConfig: {
|
186
|
-
content:
|
187
|
-
"./config/html/**/*.html",
|
188
|
-
"./config/html/**/*.ejs",
|
189
|
-
"./config/html/**/*.hbs",
|
190
|
-
"./src/**/*.js",
|
191
|
-
"./src/**/*.jsx",
|
192
|
-
"./src/**/*.ts",
|
193
|
-
"./src/**/*.tsx",
|
194
|
-
"./storybook/**/*",
|
195
|
-
"./styles/**/*.less",
|
196
|
-
"./styles/**/*.css",
|
197
|
-
"./styles/**/*.sass",
|
198
|
-
"./styles/**/*.scss"
|
199
|
-
]
|
198
|
+
content: defaultContent
|
200
199
|
}
|
201
200
|
});
|
201
|
+
var tailwindPlugin = require(tailwindPath)(tailwindConfig);
|
202
202
|
if (Array.isArray(config.postcssOptions.plugins)) {
|
203
|
-
config.postcssOptions.plugins.push(
|
203
|
+
config.postcssOptions.plugins.push(tailwindPlugin);
|
204
204
|
} else {
|
205
205
|
config.postcssOptions.plugins = [
|
206
|
-
|
206
|
+
tailwindPlugin
|
207
207
|
];
|
208
208
|
}
|
209
209
|
},
|
210
210
|
babel: function babel(_, param) {
|
211
211
|
var addPlugins = param.addPlugins;
|
212
|
-
if (
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
config: internalTwConfigPath
|
212
|
+
if (haveTwinMacro) {
|
213
|
+
addPlugins([
|
214
|
+
[
|
215
|
+
require.resolve("babel-plugin-macros"),
|
216
|
+
{
|
217
|
+
twin: {
|
218
|
+
preset: supportCssInJsLibrary,
|
219
|
+
config: internalTwConfigPath
|
220
|
+
}
|
222
221
|
}
|
223
|
-
|
224
|
-
]
|
225
|
-
|
222
|
+
]
|
223
|
+
]);
|
224
|
+
}
|
226
225
|
}
|
227
226
|
}
|
228
227
|
};
|
229
228
|
},
|
230
|
-
beforeBuildTask: function beforeBuildTask(
|
231
|
-
var config = param.config;
|
229
|
+
beforeBuildTask: function beforeBuildTask(config) {
|
232
230
|
var modernConfig = api.useResolvedConfigContext();
|
233
231
|
var designSystem = modernConfig.designSystem;
|
234
|
-
var tailwindConfig = getTailwindConfig(config.style.tailwindCss, designSystem, {
|
232
|
+
var tailwindConfig = getTailwindConfig(tailwindVersion, config.style.tailwindCss, designSystem, {
|
235
233
|
pureConfig: {
|
236
|
-
content:
|
237
|
-
"./config/html/**/*.html",
|
238
|
-
"./config/html/**/*.ejs",
|
239
|
-
"./config/html/**/*.hbs",
|
240
|
-
"./src/**/*.js",
|
241
|
-
"./src/**/*.jsx",
|
242
|
-
"./src/**/*.ts",
|
243
|
-
"./src/**/*.tsx",
|
244
|
-
"./storybook/**/*",
|
245
|
-
"./styles/**/*.less",
|
246
|
-
"./styles/**/*.css",
|
247
|
-
"./styles/**/*.sass",
|
248
|
-
"./styles/**/*.scss"
|
249
|
-
]
|
234
|
+
content: defaultContent
|
250
235
|
}
|
251
236
|
});
|
237
|
+
var tailwindPlugin = require(tailwindPath)(tailwindConfig);
|
252
238
|
if (Array.isArray(config.style.postcss.plugins)) {
|
253
|
-
config.style.postcss.plugins.push(
|
239
|
+
config.style.postcss.plugins.push(tailwindPlugin);
|
254
240
|
} else {
|
255
241
|
config.style.postcss.plugins = [
|
256
|
-
|
242
|
+
tailwindPlugin
|
257
243
|
];
|
258
244
|
}
|
259
245
|
return config;
|
@@ -64,8 +64,8 @@ var getPureDesignSystemConfig = function(designSystemConfig) {
|
|
64
64
|
delete pureDesignSystemConfig.supportStyledComponents;
|
65
65
|
return pureDesignSystemConfig;
|
66
66
|
};
|
67
|
-
var getTailwindConfig = function(tailwindcss, designSystem) {
|
68
|
-
var option = arguments.length >
|
67
|
+
var getTailwindConfig = function(tailwindVersion, tailwindcss, designSystem) {
|
68
|
+
var option = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
|
69
69
|
var purgeConfig = merge({
|
70
70
|
enabled: process.env.NODE_ENV === "production",
|
71
71
|
layers: [
|
@@ -73,7 +73,9 @@ var getTailwindConfig = function(tailwindcss, designSystem) {
|
|
73
73
|
],
|
74
74
|
content: []
|
75
75
|
}, option.pureConfig || {});
|
76
|
-
var defaultTailwindConfig = {
|
76
|
+
var defaultTailwindConfig = tailwindVersion === "3" ? {
|
77
|
+
content: purgeConfig.content
|
78
|
+
} : {
|
77
79
|
purge: purgeConfig
|
78
80
|
};
|
79
81
|
var tailwindConfig = applyOptionsChain(defaultTailwindConfig, tailwindcss || {});
|
@@ -127,7 +127,7 @@ import { fs } from "@modern-js/utils";
|
|
127
127
|
var template = function(configPath) {
|
128
128
|
return "\nfunction _interopRequireDefault(obj) {\n return obj && obj.__esModule ? obj : { default: obj };\n}\nconst modernConfig = _interopRequireDefault(require('".concat(configPath, "')).default;\n\nconst theme =\n modernConfig && modernConfig.source && modernConfig.source.designSystem\n ? modernConfig.source.designSystem\n : {};\nconst tailwindcss =\n modernConfig && modernConfig.tools && modernConfig.tools.tailwindcss\n ? modernConfig.tools.tailwindcss\n : {};\n\nmodule.exports = {\n theme,\n ...tailwindcss,\n};\n");
|
129
129
|
};
|
130
|
-
var
|
130
|
+
var checkTwinMacroExist = function() {
|
131
131
|
var _ref = _asyncToGenerator(function(appDirectory) {
|
132
132
|
var depName, packageJson;
|
133
133
|
return __generator(this, function(_state) {
|
@@ -142,21 +142,40 @@ var checkTwinMacroNotExist = function() {
|
|
142
142
|
];
|
143
143
|
case 1:
|
144
144
|
packageJson = _state.sent() || {};
|
145
|
-
if (typeof packageJson.dependencies === "object" && packageJson.dependencies[depName] || typeof packageJson.devDependencies === "object" && packageJson.devDependencies[depName]) {
|
146
|
-
return [
|
147
|
-
2,
|
148
|
-
false
|
149
|
-
];
|
150
|
-
}
|
151
145
|
return [
|
152
146
|
2,
|
153
|
-
|
147
|
+
Boolean(typeof packageJson.dependencies === "object" && packageJson.dependencies[depName] || typeof packageJson.devDependencies === "object" && packageJson.devDependencies[depName])
|
154
148
|
];
|
155
149
|
}
|
156
150
|
});
|
157
151
|
});
|
158
|
-
return function
|
152
|
+
return function checkTwinMacroExist(appDirectory) {
|
159
153
|
return _ref.apply(this, arguments);
|
160
154
|
};
|
161
155
|
}();
|
162
|
-
|
156
|
+
function getTailwindPath(appDirectory) {
|
157
|
+
try {
|
158
|
+
return require.resolve("tailwindcss", {
|
159
|
+
paths: [
|
160
|
+
appDirectory,
|
161
|
+
__dirname
|
162
|
+
]
|
163
|
+
});
|
164
|
+
} catch (err) {
|
165
|
+
return "tailwindcss";
|
166
|
+
}
|
167
|
+
}
|
168
|
+
function getTailwindVersion(appDirectory) {
|
169
|
+
try {
|
170
|
+
var packageJsonPath = require.resolve("tailwindcss/package.json", {
|
171
|
+
paths: [
|
172
|
+
appDirectory,
|
173
|
+
__dirname
|
174
|
+
]
|
175
|
+
});
|
176
|
+
return require(packageJsonPath).version.split(".")[0];
|
177
|
+
} catch (err) {
|
178
|
+
return "3";
|
179
|
+
}
|
180
|
+
}
|
181
|
+
export { checkTwinMacroExist, getTailwindPath, getTailwindVersion, template };
|
package/dist/types/tailwind.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { DesignSystem, Tailwind } from './types';
|
2
|
-
declare const getTailwindConfig: (tailwindcss?: Tailwind, designSystem?: DesignSystem, option?: {
|
2
|
+
declare const getTailwindConfig: (tailwindVersion: '2' | '3', tailwindcss?: Tailwind, designSystem?: DesignSystem, option?: {
|
3
3
|
pureConfig?: Record<string, any>;
|
4
4
|
}) => Record<string, any>;
|
5
5
|
export { getTailwindConfig };
|
package/dist/types/utils.d.ts
CHANGED
@@ -1,2 +1,4 @@
|
|
1
1
|
export declare const template: (configPath: string) => string;
|
2
|
-
export declare const
|
2
|
+
export declare const checkTwinMacroExist: (appDirectory: string) => Promise<boolean>;
|
3
|
+
export declare function getTailwindPath(appDirectory: string): string;
|
4
|
+
export declare function getTailwindVersion(appDirectory: string): '2' | '3';
|
package/package.json
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
"modern",
|
12
12
|
"modern.js"
|
13
13
|
],
|
14
|
-
"version": "2.0.0-beta.
|
14
|
+
"version": "2.0.0-beta.7",
|
15
15
|
"jsnext:source": "./src/index.ts",
|
16
16
|
"types": "./dist/types/index.d.ts",
|
17
17
|
"main": "./dist/js/node/index.js",
|
@@ -46,28 +46,27 @@
|
|
46
46
|
"@babel/runtime": "^7.18.0",
|
47
47
|
"babel-plugin-macros": "3.1.0",
|
48
48
|
"hoist-non-react-statics": "^3.3.2",
|
49
|
-
"@modern-js/utils": "2.0.0-beta.
|
49
|
+
"@modern-js/utils": "2.0.0-beta.7"
|
50
50
|
},
|
51
51
|
"devDependencies": {
|
52
52
|
"@types/jest": "^27",
|
53
53
|
"@types/node": "^14",
|
54
|
-
"@types/tailwindcss": "^2.2.1",
|
55
54
|
"typescript": "^4",
|
56
|
-
"tailwindcss": "^2.
|
55
|
+
"tailwindcss": "^3.2.4",
|
57
56
|
"jest": "^27",
|
58
57
|
"react": "^18",
|
59
58
|
"postcss": "^8.4.14",
|
60
|
-
"@modern-js/core": "2.0.0-beta.
|
61
|
-
"@modern-js/module-tools": "2.0.0-beta.
|
62
|
-
"@modern-js/runtime": "2.0.0-beta.
|
63
|
-
"@modern-js/types": "2.0.0-beta.
|
64
|
-
"@scripts/build": "2.0.0-beta.
|
65
|
-
"@modern-js/app-tools": "2.0.0-beta.
|
66
|
-
"@scripts/jest-config": "2.0.0-beta.
|
59
|
+
"@modern-js/core": "2.0.0-beta.7",
|
60
|
+
"@modern-js/module-tools": "2.0.0-beta.7",
|
61
|
+
"@modern-js/runtime": "2.0.0-beta.7",
|
62
|
+
"@modern-js/types": "2.0.0-beta.7",
|
63
|
+
"@scripts/build": "2.0.0-beta.7",
|
64
|
+
"@modern-js/app-tools": "2.0.0-beta.7",
|
65
|
+
"@scripts/jest-config": "2.0.0-beta.7"
|
67
66
|
},
|
68
67
|
"peerDependencies": {
|
69
|
-
"tailwindcss": "
|
70
|
-
"@modern-js/runtime": "^2.0.0-beta.
|
68
|
+
"tailwindcss": ">= 2.0.0 || >= 3.0.0",
|
69
|
+
"@modern-js/runtime": "^2.0.0-beta.7"
|
71
70
|
},
|
72
71
|
"peerDependenciesMeta": {
|
73
72
|
"@modern-js/runtime": {
|