@modern-js/plugin-tailwindcss 2.0.0-beta.2 → 2.0.0-beta.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/CHANGELOG.md CHANGED
@@ -1,5 +1,89 @@
1
1
  # @modern-js/plugin-tailwindcss
2
2
 
3
+ ## 2.0.0-beta.3
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
+ - d6546ad: add buildConfig style in module-tools-v2 and remove tools
44
+ 在 module-tools-v2 里新增 buildConfig style 并删除 tools
45
+ - Updated dependencies [2344eb26ed]
46
+ - Updated dependencies [a11fcf8b50]
47
+ - Updated dependencies [e7ce063]
48
+ - Updated dependencies [b18fa8f3ed]
49
+ - Updated dependencies [c9e800d39a]
50
+ - Updated dependencies [6604f1b]
51
+ - Updated dependencies [6aca875]
52
+ - Updated dependencies [fda836f]
53
+ - Updated dependencies [3e57f2bd58]
54
+ - Updated dependencies [2e60319]
55
+ - Updated dependencies [fbf5eed5aa]
56
+ - Updated dependencies [a2509bfbdb]
57
+ - Updated dependencies [425e570]
58
+ - Updated dependencies [e4357f1]
59
+ - Updated dependencies [4369648ae2]
60
+ - Updated dependencies [92f0eade39]
61
+ - Updated dependencies [92c0994468]
62
+ - Updated dependencies [edd1cfb1af]
63
+ - Updated dependencies [cc971eabfc]
64
+ - Updated dependencies [5b9049f2e9]
65
+ - Updated dependencies [6bda14ed71]
66
+ - Updated dependencies [92004d1906]
67
+ - Updated dependencies [b8bbe036c7]
68
+ - Updated dependencies [40ed5874c6]
69
+ - Updated dependencies [60d5378632]
70
+ - Updated dependencies [d5a31df781]
71
+ - Updated dependencies [dda38c9c3e]
72
+ - Updated dependencies [8b8e1bb571]
73
+ - Updated dependencies [3bbea92b2a]
74
+ - Updated dependencies [b710adb]
75
+ - Updated dependencies [18aaf42249]
76
+ - Updated dependencies [34702d5]
77
+ - Updated dependencies [fcace5b5b9]
78
+ - Updated dependencies [ea7cf06]
79
+ - Updated dependencies [bbe4c4a]
80
+ - Updated dependencies [e4558a0]
81
+ - Updated dependencies [abf3421a75]
82
+ - Updated dependencies [543be9558e]
83
+ - Updated dependencies [14b712da84]
84
+ - @modern-js/runtime@2.0.0-beta.3
85
+ - @modern-js/utils@2.0.0-beta.3
86
+
3
87
  ## 2.0.0-beta.2
4
88
 
5
89
  ### Major Changes
@@ -51,38 +51,19 @@ export default (({
51
51
  // TODO: Add interface about postcss config
52
52
  // TODO: In module project, also is called, but should not be called.
53
53
  postcss: config => {
54
+ var _modernConfig$tools, _modernConfig$source;
54
55
  const modernConfig = api.useResolvedConfigContext();
55
- if (!config.postcssOptions
56
- // config.$$tools === 'module-tools'
57
- ) {
58
- if (Array.isArray(config.plugins)) {
59
- const tailwindConfig = getTailwindConfig(modernConfig, {
60
- pureConfig: {
61
- content: ['./src/**/*.js', './src/**/*.jsx', './src/**/*.ts', './src/**/*.tsx', './src/**/*.less', './src/**/*.css', './src/**/*.sass', './src/**/*.scss', './styles/**/*.less', './styles/**/*.css', './styles/**/*.sass', './styles/**/*.scss']
62
- }
63
- });
64
- config.plugins.push(require('tailwindcss')(tailwindConfig));
65
- } else {
66
- const tailwindConfig = getTailwindConfig(modernConfig, {
67
- pureConfig: {
68
- content: ['./src/**/*.js', './src/**/*.jsx', './src/**/*.ts', './src/**/*.tsx', './src/**/*.less', './src/**/*.css', './src/**/*.sass', './src/**/*.scss', './styles/**/*.less', './styles/**/*.css', './styles/**/*.sass', './styles/**/*.scss']
69
- }
70
- });
71
- config.plugins = [require('tailwindcss')(tailwindConfig)];
56
+ const tailwindConfig = getTailwindConfig(modernConfig === null || modernConfig === void 0 ? void 0 : (_modernConfig$tools = modernConfig.tools) === null || _modernConfig$tools === void 0 ? void 0 : _modernConfig$tools.tailwindcss, modernConfig === null || modernConfig === void 0 ? void 0 : (_modernConfig$source = modernConfig.source) === null || _modernConfig$source === void 0 ? void 0 : _modernConfig$source.designSystem, {
57
+ pureConfig: {
58
+ content: ['./config/html/**/*.html', './config/html/**/*.ejs', './config/html/**/*.hbs', './src/**/*.js', './src/**/*.jsx', './src/**/*.ts', './src/**/*.tsx',
59
+ // about storybook
60
+ './storybook/**/*', './styles/**/*.less', './styles/**/*.css', './styles/**/*.sass', './styles/**/*.scss']
72
61
  }
62
+ });
63
+ if (Array.isArray(config.postcssOptions.plugins)) {
64
+ config.postcssOptions.plugins.push(require('tailwindcss')(tailwindConfig));
73
65
  } else {
74
- const tailwindConfig = getTailwindConfig(modernConfig, {
75
- pureConfig: {
76
- content: ['./config/html/**/*.html', './config/html/**/*.ejs', './config/html/**/*.hbs', './src/**/*.js', './src/**/*.jsx', './src/**/*.ts', './src/**/*.tsx',
77
- // about storybook
78
- './storybook/**/*', './styles/**/*.less', './styles/**/*.css', './styles/**/*.sass', './styles/**/*.scss']
79
- }
80
- });
81
- if (Array.isArray(config.postcssOptions.plugins)) {
82
- config.postcssOptions.plugins.push(require('tailwindcss')(tailwindConfig));
83
- } else {
84
- config.postcssOptions.plugins = [require('tailwindcss')(tailwindConfig)];
85
- }
66
+ config.postcssOptions.plugins = [require('tailwindcss')(tailwindConfig)];
86
67
  }
87
68
  },
88
69
  babel(config) {
@@ -116,6 +97,27 @@ export default (({
116
97
  }
117
98
  }
118
99
  };
100
+ },
101
+ beforeBuildTask({
102
+ config
103
+ }) {
104
+ const modernConfig = api.useResolvedConfigContext();
105
+ const {
106
+ designSystem
107
+ } = modernConfig;
108
+ const tailwindConfig = getTailwindConfig(config.style.tailwindCss, designSystem, {
109
+ pureConfig: {
110
+ content: ['./config/html/**/*.html', './config/html/**/*.ejs', './config/html/**/*.hbs', './src/**/*.js', './src/**/*.jsx', './src/**/*.ts', './src/**/*.tsx',
111
+ // about storybook
112
+ './storybook/**/*', './styles/**/*.less', './styles/**/*.css', './styles/**/*.sass', './styles/**/*.scss']
113
+ }
114
+ });
115
+ if (Array.isArray(config.style.postcss.plugins)) {
116
+ config.style.postcss.plugins.push(require('tailwindcss')(tailwindConfig));
117
+ } else {
118
+ config.style.postcss.plugins = [require('tailwindcss')(tailwindConfig)];
119
+ }
120
+ return config;
119
121
  }
120
122
  };
121
123
  }
@@ -12,9 +12,7 @@ export default (({
12
12
  let pluginsExportsUtils;
13
13
  const resolveConfig = lazyImport('tailwindcss/resolveConfig', require);
14
14
  const PLUGIN_IDENTIFIER = 'designToken';
15
- const getDesignTokens = userConfig => {
16
- var _userConfig$source;
17
- const designSystem = (_userConfig$source = userConfig.source) === null || _userConfig$source === void 0 ? void 0 : _userConfig$source.designSystem;
15
+ const getDesignTokens = designSystem => {
18
16
  const tailwindcssConfig = {};
19
17
  tailwindcssConfig.theme = designSystem ? _objectSpread({}, designSystem) : {};
20
18
 
@@ -51,11 +49,11 @@ export default (({
51
49
  entrypoint,
52
50
  imports
53
51
  }) {
54
- var _userConfig$source$de, _userConfig$source2;
52
+ var _userConfig$source$de, _userConfig$source;
55
53
  const userConfig = api.useResolvedConfigContext();
56
- const designSystem = (_userConfig$source$de = (_userConfig$source2 = userConfig.source) === null || _userConfig$source2 === void 0 ? void 0 : _userConfig$source2.designSystem) !== null && _userConfig$source$de !== void 0 ? _userConfig$source$de : {};
54
+ const designSystem = (_userConfig$source$de = (_userConfig$source = userConfig.source) === null || _userConfig$source === void 0 ? void 0 : _userConfig$source.designSystem) !== null && _userConfig$source$de !== void 0 ? _userConfig$source$de : {};
57
55
  if (typeof designSystem === 'object' && designSystem.supportStyledComponents) {
58
- const designTokens = getDesignTokens(userConfig);
56
+ const designTokens = getDesignTokens(userConfig.source.designSystem);
59
57
  imports.push({
60
58
  value: '@modern-js/runtime/plugins',
61
59
  specifiers: [{
@@ -75,9 +73,9 @@ export default (({
75
73
  entrypoint,
76
74
  plugins
77
75
  }) {
78
- var _userConfig$source$de2, _userConfig$source3;
76
+ var _userConfig$source$de2, _userConfig$source2;
79
77
  const userConfig = api.useResolvedConfigContext();
80
- const designSystem = (_userConfig$source$de2 = (_userConfig$source3 = userConfig.source) === null || _userConfig$source3 === void 0 ? void 0 : _userConfig$source3.designSystem) !== null && _userConfig$source$de2 !== void 0 ? _userConfig$source$de2 : {};
78
+ const designSystem = (_userConfig$source$de2 = (_userConfig$source2 = userConfig.source) === null || _userConfig$source2 === void 0 ? void 0 : _userConfig$source2.designSystem) !== null && _userConfig$source$de2 !== void 0 ? _userConfig$source$de2 : {};
81
79
  let useSCThemeProvider = true;
82
80
  if (designSystem) {
83
81
  // when designSystem exist, designToken.styledComponents`s default value is false.
@@ -11,8 +11,7 @@ const getPureDesignSystemConfig = designSystemConfig => {
11
11
  delete pureDesignSystemConfig.supportStyledComponents;
12
12
  return pureDesignSystemConfig;
13
13
  };
14
- const getTailwindConfig = (config, option = {}) => {
15
- var _config$tools, _ref, _designSystem;
14
+ const getTailwindConfig = (tailwindcss, designSystem, option = {}) => {
16
15
  const purgeConfig = merge({
17
16
  // TODO: how the operating environment is determined
18
17
  enabled: process.env.NODE_ENV === 'production',
@@ -23,8 +22,8 @@ const getTailwindConfig = (config, option = {}) => {
23
22
  const defaultTailwindConfig = {
24
23
  purge: purgeConfig
25
24
  };
26
- const tailwindConfig = applyOptionsChain(defaultTailwindConfig, ((_config$tools = config.tools) === null || _config$tools === void 0 ? void 0 : _config$tools.tailwindcss) || {});
27
- const designSystem = getPureDesignSystemConfig((_ref = (_designSystem = config.designSystem) !== null && _designSystem !== void 0 ? _designSystem : config.source.designSystem) !== null && _ref !== void 0 ? _ref : {});
25
+ const tailwindConfig = applyOptionsChain(defaultTailwindConfig, tailwindcss || {});
26
+ const designSystemConfig = getPureDesignSystemConfig(designSystem !== null && designSystem !== void 0 ? designSystem : {});
28
27
  const [exist, key] = checkIfExistNotAllowKeys(tailwindConfig);
29
28
  if (exist) {
30
29
  logger.error(`should not exist '${key}' on tools.tailwindcss, please remove it`);
@@ -33,7 +32,7 @@ const getTailwindConfig = (config, option = {}) => {
33
32
  }
34
33
 
35
34
  // Because there is no default theme configuration
36
- tailwindConfig.theme = designSystem || {};
35
+ tailwindConfig.theme = designSystemConfig || {};
37
36
  return tailwindConfig;
38
37
  };
39
38
  export { getTailwindConfig };
@@ -59,38 +59,19 @@ var _default = ({
59
59
  // TODO: Add interface about postcss config
60
60
  // TODO: In module project, also is called, but should not be called.
61
61
  postcss: config => {
62
+ var _modernConfig$tools, _modernConfig$source;
62
63
  const modernConfig = api.useResolvedConfigContext();
63
- if (!config.postcssOptions
64
- // config.$$tools === 'module-tools'
65
- ) {
66
- if (Array.isArray(config.plugins)) {
67
- const tailwindConfig = (0, _tailwind.getTailwindConfig)(modernConfig, {
68
- pureConfig: {
69
- content: ['./src/**/*.js', './src/**/*.jsx', './src/**/*.ts', './src/**/*.tsx', './src/**/*.less', './src/**/*.css', './src/**/*.sass', './src/**/*.scss', './styles/**/*.less', './styles/**/*.css', './styles/**/*.sass', './styles/**/*.scss']
70
- }
71
- });
72
- config.plugins.push(require('tailwindcss')(tailwindConfig));
73
- } else {
74
- const tailwindConfig = (0, _tailwind.getTailwindConfig)(modernConfig, {
75
- pureConfig: {
76
- content: ['./src/**/*.js', './src/**/*.jsx', './src/**/*.ts', './src/**/*.tsx', './src/**/*.less', './src/**/*.css', './src/**/*.sass', './src/**/*.scss', './styles/**/*.less', './styles/**/*.css', './styles/**/*.sass', './styles/**/*.scss']
77
- }
78
- });
79
- config.plugins = [require('tailwindcss')(tailwindConfig)];
64
+ const tailwindConfig = (0, _tailwind.getTailwindConfig)(modernConfig === null || modernConfig === void 0 ? void 0 : (_modernConfig$tools = modernConfig.tools) === null || _modernConfig$tools === void 0 ? void 0 : _modernConfig$tools.tailwindcss, modernConfig === null || modernConfig === void 0 ? void 0 : (_modernConfig$source = modernConfig.source) === null || _modernConfig$source === void 0 ? void 0 : _modernConfig$source.designSystem, {
65
+ pureConfig: {
66
+ content: ['./config/html/**/*.html', './config/html/**/*.ejs', './config/html/**/*.hbs', './src/**/*.js', './src/**/*.jsx', './src/**/*.ts', './src/**/*.tsx',
67
+ // about storybook
68
+ './storybook/**/*', './styles/**/*.less', './styles/**/*.css', './styles/**/*.sass', './styles/**/*.scss']
80
69
  }
70
+ });
71
+ if (Array.isArray(config.postcssOptions.plugins)) {
72
+ config.postcssOptions.plugins.push(require('tailwindcss')(tailwindConfig));
81
73
  } else {
82
- const tailwindConfig = (0, _tailwind.getTailwindConfig)(modernConfig, {
83
- pureConfig: {
84
- content: ['./config/html/**/*.html', './config/html/**/*.ejs', './config/html/**/*.hbs', './src/**/*.js', './src/**/*.jsx', './src/**/*.ts', './src/**/*.tsx',
85
- // about storybook
86
- './storybook/**/*', './styles/**/*.less', './styles/**/*.css', './styles/**/*.sass', './styles/**/*.scss']
87
- }
88
- });
89
- if (Array.isArray(config.postcssOptions.plugins)) {
90
- config.postcssOptions.plugins.push(require('tailwindcss')(tailwindConfig));
91
- } else {
92
- config.postcssOptions.plugins = [require('tailwindcss')(tailwindConfig)];
93
- }
74
+ config.postcssOptions.plugins = [require('tailwindcss')(tailwindConfig)];
94
75
  }
95
76
  },
96
77
  babel(config) {
@@ -124,6 +105,27 @@ var _default = ({
124
105
  }
125
106
  }
126
107
  };
108
+ },
109
+ beforeBuildTask({
110
+ config
111
+ }) {
112
+ const modernConfig = api.useResolvedConfigContext();
113
+ const {
114
+ designSystem
115
+ } = modernConfig;
116
+ const tailwindConfig = (0, _tailwind.getTailwindConfig)(config.style.tailwindCss, designSystem, {
117
+ pureConfig: {
118
+ content: ['./config/html/**/*.html', './config/html/**/*.ejs', './config/html/**/*.hbs', './src/**/*.js', './src/**/*.jsx', './src/**/*.ts', './src/**/*.tsx',
119
+ // about storybook
120
+ './storybook/**/*', './styles/**/*.less', './styles/**/*.css', './styles/**/*.sass', './styles/**/*.scss']
121
+ }
122
+ });
123
+ if (Array.isArray(config.style.postcss.plugins)) {
124
+ config.style.postcss.plugins.push(require('tailwindcss')(tailwindConfig));
125
+ } else {
126
+ config.style.postcss.plugins = [require('tailwindcss')(tailwindConfig)];
127
+ }
128
+ return config;
127
129
  }
128
130
  };
129
131
  }
@@ -18,9 +18,7 @@ var _default = ({
18
18
  let pluginsExportsUtils;
19
19
  const resolveConfig = (0, _utils.lazyImport)('tailwindcss/resolveConfig', require);
20
20
  const PLUGIN_IDENTIFIER = 'designToken';
21
- const getDesignTokens = userConfig => {
22
- var _userConfig$source;
23
- const designSystem = (_userConfig$source = userConfig.source) === null || _userConfig$source === void 0 ? void 0 : _userConfig$source.designSystem;
21
+ const getDesignTokens = designSystem => {
24
22
  const tailwindcssConfig = {};
25
23
  tailwindcssConfig.theme = designSystem ? _objectSpread({}, designSystem) : {};
26
24
 
@@ -57,11 +55,11 @@ var _default = ({
57
55
  entrypoint,
58
56
  imports
59
57
  }) {
60
- var _userConfig$source$de, _userConfig$source2;
58
+ var _userConfig$source$de, _userConfig$source;
61
59
  const userConfig = api.useResolvedConfigContext();
62
- const designSystem = (_userConfig$source$de = (_userConfig$source2 = userConfig.source) === null || _userConfig$source2 === void 0 ? void 0 : _userConfig$source2.designSystem) !== null && _userConfig$source$de !== void 0 ? _userConfig$source$de : {};
60
+ const designSystem = (_userConfig$source$de = (_userConfig$source = userConfig.source) === null || _userConfig$source === void 0 ? void 0 : _userConfig$source.designSystem) !== null && _userConfig$source$de !== void 0 ? _userConfig$source$de : {};
63
61
  if (typeof designSystem === 'object' && designSystem.supportStyledComponents) {
64
- const designTokens = getDesignTokens(userConfig);
62
+ const designTokens = getDesignTokens(userConfig.source.designSystem);
65
63
  imports.push({
66
64
  value: '@modern-js/runtime/plugins',
67
65
  specifiers: [{
@@ -81,9 +79,9 @@ var _default = ({
81
79
  entrypoint,
82
80
  plugins
83
81
  }) {
84
- var _userConfig$source$de2, _userConfig$source3;
82
+ var _userConfig$source$de2, _userConfig$source2;
85
83
  const userConfig = api.useResolvedConfigContext();
86
- const designSystem = (_userConfig$source$de2 = (_userConfig$source3 = userConfig.source) === null || _userConfig$source3 === void 0 ? void 0 : _userConfig$source3.designSystem) !== null && _userConfig$source$de2 !== void 0 ? _userConfig$source$de2 : {};
84
+ const designSystem = (_userConfig$source$de2 = (_userConfig$source2 = userConfig.source) === null || _userConfig$source2 === void 0 ? void 0 : _userConfig$source2.designSystem) !== null && _userConfig$source$de2 !== void 0 ? _userConfig$source$de2 : {};
87
85
  let useSCThemeProvider = true;
88
86
  if (designSystem) {
89
87
  // when designSystem exist, designToken.styledComponents`s default value is false.
@@ -17,8 +17,7 @@ const getPureDesignSystemConfig = designSystemConfig => {
17
17
  delete pureDesignSystemConfig.supportStyledComponents;
18
18
  return pureDesignSystemConfig;
19
19
  };
20
- const getTailwindConfig = (config, option = {}) => {
21
- var _config$tools, _ref, _designSystem;
20
+ const getTailwindConfig = (tailwindcss, designSystem, option = {}) => {
22
21
  const purgeConfig = (0, _lodash.merge)({
23
22
  // TODO: how the operating environment is determined
24
23
  enabled: process.env.NODE_ENV === 'production',
@@ -29,8 +28,8 @@ const getTailwindConfig = (config, option = {}) => {
29
28
  const defaultTailwindConfig = {
30
29
  purge: purgeConfig
31
30
  };
32
- const tailwindConfig = (0, _utils.applyOptionsChain)(defaultTailwindConfig, ((_config$tools = config.tools) === null || _config$tools === void 0 ? void 0 : _config$tools.tailwindcss) || {});
33
- const designSystem = getPureDesignSystemConfig((_ref = (_designSystem = config.designSystem) !== null && _designSystem !== void 0 ? _designSystem : config.source.designSystem) !== null && _ref !== void 0 ? _ref : {});
31
+ const tailwindConfig = (0, _utils.applyOptionsChain)(defaultTailwindConfig, tailwindcss || {});
32
+ const designSystemConfig = getPureDesignSystemConfig(designSystem !== null && designSystem !== void 0 ? designSystem : {});
34
33
  const [exist, key] = checkIfExistNotAllowKeys(tailwindConfig);
35
34
  if (exist) {
36
35
  _utils.logger.error(`should not exist '${key}' on tools.tailwindcss, please remove it`);
@@ -39,7 +38,7 @@ const getTailwindConfig = (config, option = {}) => {
39
38
  }
40
39
 
41
40
  // Because there is no default theme configuration
42
- tailwindConfig.theme = designSystem || {};
41
+ tailwindConfig.theme = designSystemConfig || {};
43
42
  return tailwindConfig;
44
43
  };
45
44
  exports.getTailwindConfig = getTailwindConfig;
@@ -57,38 +57,19 @@ export default (function () {
57
57
  // TODO: Add interface about postcss config
58
58
  // TODO: In module project, also is called, but should not be called.
59
59
  postcss: function postcss(config) {
60
+ var _modernConfig$tools, _modernConfig$source;
60
61
  var modernConfig = api.useResolvedConfigContext();
61
- if (!config.postcssOptions
62
- // config.$$tools === 'module-tools'
63
- ) {
64
- if (Array.isArray(config.plugins)) {
65
- var tailwindConfig = getTailwindConfig(modernConfig, {
66
- pureConfig: {
67
- content: ['./src/**/*.js', './src/**/*.jsx', './src/**/*.ts', './src/**/*.tsx', './src/**/*.less', './src/**/*.css', './src/**/*.sass', './src/**/*.scss', './styles/**/*.less', './styles/**/*.css', './styles/**/*.sass', './styles/**/*.scss']
68
- }
69
- });
70
- config.plugins.push(require('tailwindcss')(tailwindConfig));
71
- } else {
72
- var _tailwindConfig = getTailwindConfig(modernConfig, {
73
- pureConfig: {
74
- content: ['./src/**/*.js', './src/**/*.jsx', './src/**/*.ts', './src/**/*.tsx', './src/**/*.less', './src/**/*.css', './src/**/*.sass', './src/**/*.scss', './styles/**/*.less', './styles/**/*.css', './styles/**/*.sass', './styles/**/*.scss']
75
- }
76
- });
77
- config.plugins = [require('tailwindcss')(_tailwindConfig)];
62
+ var tailwindConfig = getTailwindConfig(modernConfig === null || modernConfig === void 0 ? void 0 : (_modernConfig$tools = modernConfig.tools) === null || _modernConfig$tools === void 0 ? void 0 : _modernConfig$tools.tailwindcss, modernConfig === null || modernConfig === void 0 ? void 0 : (_modernConfig$source = modernConfig.source) === null || _modernConfig$source === void 0 ? void 0 : _modernConfig$source.designSystem, {
63
+ pureConfig: {
64
+ content: ['./config/html/**/*.html', './config/html/**/*.ejs', './config/html/**/*.hbs', './src/**/*.js', './src/**/*.jsx', './src/**/*.ts', './src/**/*.tsx',
65
+ // about storybook
66
+ './storybook/**/*', './styles/**/*.less', './styles/**/*.css', './styles/**/*.sass', './styles/**/*.scss']
78
67
  }
68
+ });
69
+ if (Array.isArray(config.postcssOptions.plugins)) {
70
+ config.postcssOptions.plugins.push(require('tailwindcss')(tailwindConfig));
79
71
  } else {
80
- var _tailwindConfig2 = getTailwindConfig(modernConfig, {
81
- pureConfig: {
82
- content: ['./config/html/**/*.html', './config/html/**/*.ejs', './config/html/**/*.hbs', './src/**/*.js', './src/**/*.jsx', './src/**/*.ts', './src/**/*.tsx',
83
- // about storybook
84
- './storybook/**/*', './styles/**/*.less', './styles/**/*.css', './styles/**/*.sass', './styles/**/*.scss']
85
- }
86
- });
87
- if (Array.isArray(config.postcssOptions.plugins)) {
88
- config.postcssOptions.plugins.push(require('tailwindcss')(_tailwindConfig2));
89
- } else {
90
- config.postcssOptions.plugins = [require('tailwindcss')(_tailwindConfig2)];
91
- }
72
+ config.postcssOptions.plugins = [require('tailwindcss')(tailwindConfig)];
92
73
  }
93
74
  },
94
75
  babel: function babel(config) {
@@ -122,6 +103,24 @@ export default (function () {
122
103
  }
123
104
  }
124
105
  };
106
+ },
107
+ beforeBuildTask: function beforeBuildTask(_ref2) {
108
+ var config = _ref2.config;
109
+ var modernConfig = api.useResolvedConfigContext();
110
+ var designSystem = modernConfig.designSystem;
111
+ var tailwindConfig = getTailwindConfig(config.style.tailwindCss, designSystem, {
112
+ pureConfig: {
113
+ content: ['./config/html/**/*.html', './config/html/**/*.ejs', './config/html/**/*.hbs', './src/**/*.js', './src/**/*.jsx', './src/**/*.ts', './src/**/*.tsx',
114
+ // about storybook
115
+ './storybook/**/*', './styles/**/*.less', './styles/**/*.css', './styles/**/*.sass', './styles/**/*.scss']
116
+ }
117
+ });
118
+ if (Array.isArray(config.style.postcss.plugins)) {
119
+ config.style.postcss.plugins.push(require('tailwindcss')(tailwindConfig));
120
+ } else {
121
+ config.style.postcss.plugins = [require('tailwindcss')(tailwindConfig)];
122
+ }
123
+ return config;
125
124
  }
126
125
  });
127
126
  case 6:
@@ -12,9 +12,7 @@ export default (function () {
12
12
  var pluginsExportsUtils;
13
13
  var resolveConfig = lazyImport('tailwindcss/resolveConfig', require);
14
14
  var PLUGIN_IDENTIFIER = 'designToken';
15
- var getDesignTokens = function getDesignTokens(userConfig) {
16
- var _userConfig$source;
17
- var designSystem = (_userConfig$source = userConfig.source) === null || _userConfig$source === void 0 ? void 0 : _userConfig$source.designSystem;
15
+ var getDesignTokens = function getDesignTokens(designSystem) {
18
16
  var tailwindcssConfig = {};
19
17
  tailwindcssConfig.theme = designSystem ? _objectSpread({}, designSystem) : {};
20
18
 
@@ -48,13 +46,13 @@ export default (function () {
48
46
  };
49
47
  },
50
48
  modifyEntryImports: function modifyEntryImports(_ref2) {
51
- var _userConfig$source$de, _userConfig$source2;
49
+ var _userConfig$source$de, _userConfig$source;
52
50
  var entrypoint = _ref2.entrypoint,
53
51
  imports = _ref2.imports;
54
52
  var userConfig = api.useResolvedConfigContext();
55
- var designSystem = (_userConfig$source$de = (_userConfig$source2 = userConfig.source) === null || _userConfig$source2 === void 0 ? void 0 : _userConfig$source2.designSystem) !== null && _userConfig$source$de !== void 0 ? _userConfig$source$de : {};
53
+ var designSystem = (_userConfig$source$de = (_userConfig$source = userConfig.source) === null || _userConfig$source === void 0 ? void 0 : _userConfig$source.designSystem) !== null && _userConfig$source$de !== void 0 ? _userConfig$source$de : {};
56
54
  if (_typeof(designSystem) === 'object' && designSystem.supportStyledComponents) {
57
- var designTokens = getDesignTokens(userConfig);
55
+ var designTokens = getDesignTokens(userConfig.source.designSystem);
58
56
  imports.push({
59
57
  value: '@modern-js/runtime/plugins',
60
58
  specifiers: [{
@@ -69,11 +67,11 @@ export default (function () {
69
67
  };
70
68
  },
71
69
  modifyEntryRuntimePlugins: function modifyEntryRuntimePlugins(_ref3) {
72
- var _userConfig$source$de2, _userConfig$source3;
70
+ var _userConfig$source$de2, _userConfig$source2;
73
71
  var entrypoint = _ref3.entrypoint,
74
72
  plugins = _ref3.plugins;
75
73
  var userConfig = api.useResolvedConfigContext();
76
- var designSystem = (_userConfig$source$de2 = (_userConfig$source3 = userConfig.source) === null || _userConfig$source3 === void 0 ? void 0 : _userConfig$source3.designSystem) !== null && _userConfig$source$de2 !== void 0 ? _userConfig$source$de2 : {};
74
+ var designSystem = (_userConfig$source$de2 = (_userConfig$source2 = userConfig.source) === null || _userConfig$source2 === void 0 ? void 0 : _userConfig$source2.designSystem) !== null && _userConfig$source$de2 !== void 0 ? _userConfig$source$de2 : {};
77
75
  var useSCThemeProvider = true;
78
76
  if (designSystem) {
79
77
  // when designSystem exist, designToken.styledComponents`s default value is false.
@@ -14,9 +14,8 @@ var getPureDesignSystemConfig = function getPureDesignSystemConfig(designSystemC
14
14
  delete pureDesignSystemConfig.supportStyledComponents;
15
15
  return pureDesignSystemConfig;
16
16
  };
17
- var getTailwindConfig = function getTailwindConfig(config) {
18
- var _config$tools, _ref, _designSystem;
19
- var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
17
+ var getTailwindConfig = function getTailwindConfig(tailwindcss, designSystem) {
18
+ var option = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
20
19
  var purgeConfig = merge({
21
20
  // TODO: how the operating environment is determined
22
21
  enabled: process.env.NODE_ENV === 'production',
@@ -27,8 +26,8 @@ var getTailwindConfig = function getTailwindConfig(config) {
27
26
  var defaultTailwindConfig = {
28
27
  purge: purgeConfig
29
28
  };
30
- var tailwindConfig = applyOptionsChain(defaultTailwindConfig, ((_config$tools = config.tools) === null || _config$tools === void 0 ? void 0 : _config$tools.tailwindcss) || {});
31
- var designSystem = getPureDesignSystemConfig((_ref = (_designSystem = config.designSystem) !== null && _designSystem !== void 0 ? _designSystem : config.source.designSystem) !== null && _ref !== void 0 ? _ref : {});
29
+ var tailwindConfig = applyOptionsChain(defaultTailwindConfig, tailwindcss || {});
30
+ var designSystemConfig = getPureDesignSystemConfig(designSystem !== null && designSystem !== void 0 ? designSystem : {});
32
31
  var _checkIfExistNotAllow = checkIfExistNotAllowKeys(tailwindConfig),
33
32
  _checkIfExistNotAllow2 = _slicedToArray(_checkIfExistNotAllow, 2),
34
33
  exist = _checkIfExistNotAllow2[0],
@@ -40,7 +39,7 @@ var getTailwindConfig = function getTailwindConfig(config) {
40
39
  }
41
40
 
42
41
  // Because there is no default theme configuration
43
- tailwindConfig.theme = designSystem || {};
42
+ tailwindConfig.theme = designSystemConfig || {};
44
43
  return tailwindConfig;
45
44
  };
46
45
  export { getTailwindConfig };
@@ -1,8 +1,9 @@
1
- import type { LegacyAppTools, CliPlugin } from '@modern-js/app-tools';
1
+ import type { LegacyAppTools } from '@modern-js/app-tools';
2
+ import type { CliPlugin, ModuleTools } from '@modern-js/module-tools-v2';
2
3
  export declare const getRandomTwConfigFileName: (internalDirectory: string) => string;
3
4
  declare const _default: ({
4
5
  pluginName
5
6
  }?: {
6
7
  pluginName: string;
7
- }) => CliPlugin<LegacyAppTools>;
8
+ }) => CliPlugin<LegacyAppTools & ModuleTools>;
8
9
  export default _default;
@@ -1,5 +1,5 @@
1
- import type { AppLegacyNormalizedConfig } from '@modern-js/app-tools';
2
- declare const getTailwindConfig: (config: AppLegacyNormalizedConfig, option?: {
1
+ import { DesignSystem, Tailwind } from './types';
2
+ declare const getTailwindConfig: (tailwindcss?: Tailwind, designSystem?: DesignSystem, option?: {
3
3
  pureConfig?: Record<string, any>;
4
- }) => any;
4
+ }) => Record<string, any>;
5
5
  export { getTailwindConfig };
@@ -1,10 +1,4 @@
1
- export declare type LegacyUserConfig = {
2
- designSystem?: Record<string, any> & {
3
- supportStyledComponents?: boolean;
4
- };
5
- source?: {
6
- designSystem?: Record<string, any> & {
7
- supportStyledComponents?: boolean;
8
- };
9
- };
10
- };
1
+ export declare type DesignSystem = Record<string, any> & {
2
+ supportStyledComponents?: boolean;
3
+ };
4
+ export declare type Tailwind = Record<string, any> | ((options: Record<string, any>) => Record<string, any> | void);
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "2.0.0-beta.2",
14
+ "version": "2.0.0-beta.3",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -45,7 +45,7 @@
45
45
  "dependencies": {
46
46
  "@babel/runtime": "^7.18.0",
47
47
  "hoist-non-react-statics": "^3.3.2",
48
- "@modern-js/utils": "2.0.0-beta.2"
48
+ "@modern-js/utils": "2.0.0-beta.3"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@types/jest": "^27",
@@ -56,16 +56,17 @@
56
56
  "jest": "^27",
57
57
  "react": "^18",
58
58
  "postcss": "^8.4.14",
59
- "@modern-js/core": "2.0.0-beta.2",
60
- "@modern-js/runtime": "2.0.0-beta.2",
61
- "@modern-js/types": "2.0.0-beta.2",
62
- "@scripts/build": "2.0.0-beta.2",
63
- "@modern-js/app-tools": "2.0.0-beta.2",
64
- "@scripts/jest-config": "2.0.0-beta.2"
59
+ "@modern-js/core": "2.0.0-beta.3",
60
+ "@modern-js/module-tools-v2": "2.0.0-beta.3",
61
+ "@modern-js/runtime": "2.0.0-beta.3",
62
+ "@modern-js/types": "2.0.0-beta.3",
63
+ "@scripts/build": "2.0.0-beta.3",
64
+ "@modern-js/app-tools": "2.0.0-beta.3",
65
+ "@scripts/jest-config": "2.0.0-beta.3"
65
66
  },
66
67
  "peerDependencies": {
67
68
  "tailwindcss": "^2.0.4",
68
- "@modern-js/runtime": "^2.0.0-beta.2"
69
+ "@modern-js/runtime": "^2.0.0-beta.3"
69
70
  },
70
71
  "peerDependenciesMeta": {
71
72
  "@modern-js/runtime": {