@modern-js/plugin-tailwindcss 0.0.0-next-20221122140537 → 0.0.0-next-20221123121051

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,6 +1,6 @@
1
1
  # @modern-js/plugin-tailwindcss
2
2
 
3
- ## 0.0.0-next-20221122140537
3
+ ## 0.0.0-next-20221123121051
4
4
 
5
5
  ### Major Changes
6
6
 
@@ -40,9 +40,11 @@
40
40
 
41
41
  ### Patch Changes
42
42
 
43
+ - Updated dependencies [a11fcf8b]
43
44
  - Updated dependencies [b18fa8f3]
44
45
  - Updated dependencies [c9e800d3]
45
46
  - Updated dependencies [3e57f2bd]
47
+ - Updated dependencies [fbf5eed5]
46
48
  - Updated dependencies [a2509bfb]
47
49
  - Updated dependencies [4369648a]
48
50
  - Updated dependencies [92f0eade]
@@ -63,8 +65,8 @@
63
65
  - Updated dependencies [abf3421a]
64
66
  - Updated dependencies [543be955]
65
67
  - Updated dependencies [14b712da]
66
- - @modern-js/runtime@0.0.0-next-20221122140537
67
- - @modern-js/utils@0.0.0-next-20221122140537
68
+ - @modern-js/runtime@0.0.0-next-20221123121051
69
+ - @modern-js/utils@0.0.0-next-20221123121051
68
70
 
69
71
  ## 2.0.0-beta.0
70
72
 
@@ -1,9 +1,6 @@
1
1
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
-
3
2
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
-
5
3
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
-
7
4
  import path from 'path';
8
5
  import { PLUGIN_SCHEMAS, fs, CONFIG_CACHE_DIR, globby, nanoid, slash } from '@modern-js/utils';
9
6
  import DesignTokenPlugin from "./design-token/cli";
@@ -28,30 +25,26 @@ export default (({
28
25
  appDirectory,
29
26
  internalDirectory
30
27
  } = api.useAppContext();
31
- let internalTwConfigPath = ''; // When reinstalling dependencies, most of the time the project will be restarted
32
-
28
+ let internalTwConfigPath = '';
29
+ // When reinstalling dependencies, most of the time the project will be restarted
33
30
  const notHaveTwinMacro = await checkTwinMacroNotExist(appDirectory);
34
31
  return {
35
32
  prepare() {
36
33
  if (notHaveTwinMacro) {
37
34
  return;
38
35
  }
39
-
40
36
  internalTwConfigPath = getRandomTwConfigFileName(internalDirectory);
41
37
  const globPattern = slash(path.join(appDirectory, CONFIG_CACHE_DIR, '*.cjs'));
42
38
  const files = globby.sync(globPattern, {
43
39
  absolute: true
44
40
  });
45
-
46
41
  if (files.length > 0) {
47
42
  fs.writeFileSync(internalTwConfigPath, template(files[files.length - 1]), 'utf-8');
48
43
  }
49
44
  },
50
-
51
45
  validateSchema() {
52
46
  return PLUGIN_SCHEMAS['@modern-js/plugin-tailwindcss'];
53
47
  },
54
-
55
48
  config() {
56
49
  return {
57
50
  tools: {
@@ -59,8 +52,8 @@ export default (({
59
52
  // TODO: In module project, also is called, but should not be called.
60
53
  postcss: config => {
61
54
  const modernConfig = api.useResolvedConfigContext();
62
-
63
- if (!config.postcssOptions // config.$$tools === 'module-tools'
55
+ if (!config.postcssOptions
56
+ // config.$$tools === 'module-tools'
64
57
  ) {
65
58
  if (Array.isArray(config.plugins)) {
66
59
  const tailwindConfig = getTailwindConfig(modernConfig, {
@@ -80,11 +73,11 @@ export default (({
80
73
  } else {
81
74
  const tailwindConfig = getTailwindConfig(modernConfig, {
82
75
  pureConfig: {
83
- content: ['./config/html/**/*.html', './config/html/**/*.ejs', './config/html/**/*.hbs', './src/**/*.js', './src/**/*.jsx', './src/**/*.ts', './src/**/*.tsx', // about storybook
76
+ content: ['./config/html/**/*.html', './config/html/**/*.ejs', './config/html/**/*.hbs', './src/**/*.js', './src/**/*.jsx', './src/**/*.ts', './src/**/*.tsx',
77
+ // about storybook
84
78
  './storybook/**/*', './styles/**/*.less', './styles/**/*.css', './styles/**/*.sass', './styles/**/*.scss']
85
79
  }
86
80
  });
87
-
88
81
  if (Array.isArray(config.postcssOptions.plugins)) {
89
82
  config.postcssOptions.plugins.push(require('tailwindcss')(tailwindConfig));
90
83
  } else {
@@ -92,14 +85,11 @@ export default (({
92
85
  }
93
86
  }
94
87
  },
95
-
96
88
  babel(config) {
97
89
  var _config$plugins;
98
-
99
90
  if (notHaveTwinMacro) {
100
91
  return;
101
92
  }
102
-
103
93
  const twinConfig = {
104
94
  twin: {
105
95
  preset: supportCssInJsLibrary,
@@ -110,27 +100,23 @@ export default (({
110
100
  if (Array.isArray(plugin) && plugin[0]) {
111
101
  const pluginTarget = plugin[0];
112
102
  let pluginOptions = plugin[1];
113
-
114
- if (typeof pluginTarget === 'string' && // TODO: use babel chain
103
+ if (typeof pluginTarget === 'string' &&
104
+ // TODO: use babel chain
115
105
  slash(pluginTarget).includes('compiled/babel-plugin-macros')) {
116
106
  if (pluginOptions) {
117
107
  pluginOptions = _objectSpread(_objectSpread({}, pluginOptions), twinConfig);
118
108
  } else {
119
109
  plugin.push(twinConfig);
120
110
  }
121
-
122
111
  return true;
123
112
  }
124
113
  }
125
-
126
114
  return false;
127
115
  });
128
116
  }
129
-
130
117
  }
131
118
  };
132
119
  }
133
-
134
120
  };
135
121
  }
136
122
  }));
@@ -1,9 +1,6 @@
1
1
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
-
3
2
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
-
5
3
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
-
7
4
  import { lazyImport, PLUGIN_SCHEMAS, createRuntimeExportsUtils } from '@modern-js/utils';
8
5
  export default (({
9
6
  pluginName
@@ -11,31 +8,27 @@ export default (({
11
8
  pluginName: '@modern-js/plugin-tailwindcss'
12
9
  }) => ({
13
10
  name: '@modern-js/plugin-design-token',
14
-
15
11
  setup(api) {
16
12
  let pluginsExportsUtils;
17
13
  const resolveConfig = lazyImport('tailwindcss/resolveConfig', require);
18
14
  const PLUGIN_IDENTIFIER = 'designToken';
19
-
20
15
  const getDesignTokens = userConfig => {
21
16
  var _userConfig$source;
22
-
23
17
  const designSystem = (_userConfig$source = userConfig.source) === null || _userConfig$source === void 0 ? void 0 : _userConfig$source.designSystem;
24
18
  const tailwindcssConfig = {};
25
- tailwindcssConfig.theme = designSystem ? _objectSpread({}, designSystem) : {}; // not use default design token when designToken.defaultTheme is false or theme is false
19
+ tailwindcssConfig.theme = designSystem ? _objectSpread({}, designSystem) : {};
26
20
 
21
+ // not use default design token when designToken.defaultTheme is false or theme is false
27
22
  if (!designSystem) {
28
23
  tailwindcssConfig.presets = [];
29
- } // when only designSystem exist, need remove supportStyledComponents
30
-
24
+ }
31
25
 
26
+ // when only designSystem exist, need remove supportStyledComponents
32
27
  if (designSystem) {
33
28
  delete tailwindcssConfig.theme.supportStyledComponents;
34
29
  }
35
-
36
30
  return resolveConfig(tailwindcssConfig).theme || {};
37
31
  };
38
-
39
32
  return {
40
33
  config() {
41
34
  const appContext = api.useAppContext();
@@ -46,23 +39,21 @@ export default (({
46
39
  '@modern-js/runtime/plugins': pluginsExportsUtils.getPath()
47
40
  }
48
41
  },
49
- tools: {// TODO: support less、scss、css vars
42
+ tools: {
43
+ // TODO: support less、scss、css vars
50
44
  // less: https://github.com/modern-js-dev/modern.js/pull/398/files#diff-f77c749e403fbf1fb676d5687bef3d7138a230331c849298d8afaff9b6afbc3dR166
51
45
  // sass: https://github.com/modern-js-dev/modern.js/pull/398/files#diff-f77c749e403fbf1fb676d5687bef3d7138a230331c849298d8afaff9b6afbc3dR229
52
46
  // postcss: https://github.com/modern-js-dev/modern.js/pull/398/files#diff-f77c749e403fbf1fb676d5687bef3d7138a230331c849298d8afaff9b6afbc3dR281
53
47
  }
54
48
  };
55
49
  },
56
-
57
50
  modifyEntryImports({
58
51
  entrypoint,
59
52
  imports
60
53
  }) {
61
54
  var _userConfig$source$de, _userConfig$source2;
62
-
63
55
  const userConfig = api.useResolvedConfigContext();
64
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 : {};
65
-
66
57
  if (typeof designSystem === 'object' && designSystem.supportStyledComponents) {
67
58
  const designTokens = getDesignTokens(userConfig);
68
59
  imports.push({
@@ -75,51 +66,41 @@ export default (({
75
66
  `
76
67
  });
77
68
  }
78
-
79
69
  return {
80
70
  entrypoint,
81
71
  imports
82
72
  };
83
73
  },
84
-
85
74
  modifyEntryRuntimePlugins({
86
75
  entrypoint,
87
76
  plugins
88
77
  }) {
89
78
  var _userConfig$source$de2, _userConfig$source3;
90
-
91
79
  const userConfig = api.useResolvedConfigContext();
92
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 : {};
93
81
  let useSCThemeProvider = true;
94
-
95
82
  if (designSystem) {
96
83
  // when designSystem exist, designToken.styledComponents`s default value is false.
97
84
  useSCThemeProvider = (designSystem === null || designSystem === void 0 ? void 0 : designSystem.supportStyledComponents) || false;
98
85
  }
99
-
100
86
  if (typeof designSystem === 'object' && designSystem.supportStyledComponents) {
101
87
  plugins.push({
102
88
  name: PLUGIN_IDENTIFIER,
103
89
  options: `{token: designTokens, useStyledComponentsThemeProvider: ${useSCThemeProvider ? 'true' : 'false'}, useDesignTokenContext: false}`
104
90
  });
105
91
  }
106
-
107
92
  return {
108
93
  entrypoint,
109
94
  plugins
110
95
  };
111
96
  },
112
-
113
97
  validateSchema() {
114
98
  // add source.designSystem.supportStyledComponents config
115
99
  return PLUGIN_SCHEMAS['@modern-js/plugin-design-token'];
116
100
  },
117
-
118
101
  addRuntimeExports() {
119
102
  pluginsExportsUtils.addExport(`export { default as designToken } from '${pluginName}/runtime-design-token'`);
120
103
  }
121
-
122
104
  };
123
105
  }
124
-
125
106
  }));
@@ -2,17 +2,14 @@ export default (({
2
2
  cssVarsHash: _cssVarsHash = {}
3
3
  } = {}) => ({
4
4
  postcssPlugin: 'postcss-replace-css-vars',
5
-
6
5
  Declaration(decl) {
7
6
  if (decl.value && typeof decl.value === 'string') {
8
7
  decl.value = decl.value.replace(/--\S*/g, match => {
9
8
  if (_cssVarsHash[match]) {
10
9
  return _cssVarsHash[match];
11
10
  }
12
-
13
11
  return match;
14
12
  });
15
13
  }
16
14
  }
17
-
18
15
  }));
@@ -1,9 +1,6 @@
1
1
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
-
3
2
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
-
5
3
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
-
7
4
  import hoistNonReactStatics from 'hoist-non-react-statics';
8
5
  import React, { useContext } from 'react';
9
6
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -21,12 +18,10 @@ export default ((options = {}) => ({
21
18
  useStyledComponentsThemeProvider = false,
22
19
  useDesignTokenContext = false
23
20
  } = options;
24
-
25
21
  if (useStyledComponentsThemeProvider && useDesignTokenContext) {
26
22
  const {
27
23
  ThemeProvider
28
24
  } = require('@modern-js/runtime/styled');
29
-
30
25
  return /*#__PURE__*/_jsx(ThemeProvider, {
31
26
  theme: token,
32
27
  children: /*#__PURE__*/_jsx(DesignTokenContext.Provider, {
@@ -38,7 +33,6 @@ export default ((options = {}) => ({
38
33
  const {
39
34
  ThemeProvider
40
35
  } = require('@modern-js/runtime/styled');
41
-
42
36
  return /*#__PURE__*/_jsx(ThemeProvider, {
43
37
  theme: token,
44
38
  children: /*#__PURE__*/_jsx(App, _objectSpread({}, props))
@@ -52,11 +46,9 @@ export default ((options = {}) => ({
52
46
  return /*#__PURE__*/_jsx(App, _objectSpread({}, props));
53
47
  }
54
48
  };
55
-
56
49
  return next({
57
50
  App: hoistNonReactStatics(DesignTokenAppWrapper, App)
58
51
  });
59
52
  }
60
-
61
53
  })
62
54
  }));
@@ -1,22 +1,18 @@
1
1
  import { applyOptionsChain, logger } from '@modern-js/utils';
2
2
  import { merge, cloneDeep } from '@modern-js/utils/lodash';
3
-
4
3
  const checkIfExistNotAllowKeys = tailwindConfig => {
5
4
  const notAllowExistKeys = ['theme'];
6
5
  let notAllowKey = '';
7
6
  const ret = Object.keys(tailwindConfig).some(key => notAllowExistKeys.includes(key) && (notAllowKey = key));
8
7
  return [ret, notAllowKey];
9
8
  };
10
-
11
9
  const getPureDesignSystemConfig = designSystemConfig => {
12
10
  const pureDesignSystemConfig = cloneDeep(designSystemConfig);
13
11
  delete pureDesignSystemConfig.supportStyledComponents;
14
12
  return pureDesignSystemConfig;
15
13
  };
16
-
17
14
  const getTailwindConfig = (config, option = {}) => {
18
15
  var _ref, _designSystem;
19
-
20
16
  const purgeConfig = merge({
21
17
  // TODO: how the operating environment is determined
22
18
  enabled: process.env.NODE_ENV === 'production',
@@ -30,16 +26,14 @@ const getTailwindConfig = (config, option = {}) => {
30
26
  const tailwindConfig = applyOptionsChain(defaultTailwindConfig, config.tools.tailwindcss || {});
31
27
  const designSystem = getPureDesignSystemConfig((_ref = (_designSystem = config.designSystem) !== null && _designSystem !== void 0 ? _designSystem : config.source.designSystem) !== null && _ref !== void 0 ? _ref : {});
32
28
  const [exist, key] = checkIfExistNotAllowKeys(tailwindConfig);
33
-
34
29
  if (exist) {
35
- logger.error(`should not exist '${key}' on tools.tailwindcss, please remove it`); // eslint-disable-next-line no-process-exit
36
-
30
+ logger.error(`should not exist '${key}' on tools.tailwindcss, please remove it`);
31
+ // eslint-disable-next-line no-process-exit
37
32
  process.exit(0);
38
- } // Because there is no default theme configuration
39
-
33
+ }
40
34
 
35
+ // Because there is no default theme configuration
41
36
  tailwindConfig.theme = designSystem || {};
42
37
  return tailwindConfig;
43
38
  };
44
-
45
39
  export { getTailwindConfig };
@@ -25,10 +25,8 @@ export const checkTwinMacroNotExist = async appDirectory => {
25
25
  const packageJson = (await fs.readJSON(path.join(appDirectory, 'package.json'), {
26
26
  throws: false
27
27
  })) || {};
28
-
29
28
  if (typeof packageJson.dependencies === 'object' && packageJson.dependencies[depName] || typeof packageJson.devDependencies === 'object' && packageJson.devDependencies[depName]) {
30
29
  return false;
31
30
  }
32
-
33
31
  return true;
34
32
  };
@@ -4,33 +4,20 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getRandomTwConfigFileName = exports.default = void 0;
7
-
8
7
  var _path = _interopRequireDefault(require("path"));
9
-
10
8
  var _utils = require("@modern-js/utils");
11
-
12
9
  var _cli = _interopRequireDefault(require("./design-token/cli"));
13
-
14
10
  var _tailwind = require("./tailwind");
15
-
16
11
  var _utils2 = require("./utils");
17
-
18
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
-
20
13
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
21
-
22
14
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
23
-
24
15
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
25
-
26
16
  const supportCssInJsLibrary = 'styled-components';
27
-
28
17
  const getRandomTwConfigFileName = internalDirectory => {
29
18
  return (0, _utils.slash)(_path.default.join(internalDirectory, `tailwind.config.${Date.now()}.${(0, _utils.nanoid)()}.js`));
30
19
  };
31
-
32
20
  exports.getRandomTwConfigFileName = getRandomTwConfigFileName;
33
-
34
21
  var _default = ({
35
22
  pluginName
36
23
  } = {
@@ -46,31 +33,26 @@ var _default = ({
46
33
  appDirectory,
47
34
  internalDirectory
48
35
  } = api.useAppContext();
49
- let internalTwConfigPath = ''; // When reinstalling dependencies, most of the time the project will be restarted
50
-
36
+ let internalTwConfigPath = '';
37
+ // When reinstalling dependencies, most of the time the project will be restarted
51
38
  const notHaveTwinMacro = await (0, _utils2.checkTwinMacroNotExist)(appDirectory);
52
39
  return {
53
40
  prepare() {
54
41
  if (notHaveTwinMacro) {
55
42
  return;
56
43
  }
57
-
58
44
  internalTwConfigPath = getRandomTwConfigFileName(internalDirectory);
59
45
  const globPattern = (0, _utils.slash)(_path.default.join(appDirectory, _utils.CONFIG_CACHE_DIR, '*.cjs'));
60
-
61
46
  const files = _utils.globby.sync(globPattern, {
62
47
  absolute: true
63
48
  });
64
-
65
49
  if (files.length > 0) {
66
50
  _utils.fs.writeFileSync(internalTwConfigPath, (0, _utils2.template)(files[files.length - 1]), 'utf-8');
67
51
  }
68
52
  },
69
-
70
53
  validateSchema() {
71
54
  return _utils.PLUGIN_SCHEMAS['@modern-js/plugin-tailwindcss'];
72
55
  },
73
-
74
56
  config() {
75
57
  return {
76
58
  tools: {
@@ -78,8 +60,8 @@ var _default = ({
78
60
  // TODO: In module project, also is called, but should not be called.
79
61
  postcss: config => {
80
62
  const modernConfig = api.useResolvedConfigContext();
81
-
82
- if (!config.postcssOptions // config.$$tools === 'module-tools'
63
+ if (!config.postcssOptions
64
+ // config.$$tools === 'module-tools'
83
65
  ) {
84
66
  if (Array.isArray(config.plugins)) {
85
67
  const tailwindConfig = (0, _tailwind.getTailwindConfig)(modernConfig, {
@@ -99,11 +81,11 @@ var _default = ({
99
81
  } else {
100
82
  const tailwindConfig = (0, _tailwind.getTailwindConfig)(modernConfig, {
101
83
  pureConfig: {
102
- content: ['./config/html/**/*.html', './config/html/**/*.ejs', './config/html/**/*.hbs', './src/**/*.js', './src/**/*.jsx', './src/**/*.ts', './src/**/*.tsx', // about storybook
84
+ content: ['./config/html/**/*.html', './config/html/**/*.ejs', './config/html/**/*.hbs', './src/**/*.js', './src/**/*.jsx', './src/**/*.ts', './src/**/*.tsx',
85
+ // about storybook
103
86
  './storybook/**/*', './styles/**/*.less', './styles/**/*.css', './styles/**/*.sass', './styles/**/*.scss']
104
87
  }
105
88
  });
106
-
107
89
  if (Array.isArray(config.postcssOptions.plugins)) {
108
90
  config.postcssOptions.plugins.push(require('tailwindcss')(tailwindConfig));
109
91
  } else {
@@ -111,14 +93,11 @@ var _default = ({
111
93
  }
112
94
  }
113
95
  },
114
-
115
96
  babel(config) {
116
97
  var _config$plugins;
117
-
118
98
  if (notHaveTwinMacro) {
119
99
  return;
120
100
  }
121
-
122
101
  const twinConfig = {
123
102
  twin: {
124
103
  preset: supportCssInJsLibrary,
@@ -129,29 +108,24 @@ var _default = ({
129
108
  if (Array.isArray(plugin) && plugin[0]) {
130
109
  const pluginTarget = plugin[0];
131
110
  let pluginOptions = plugin[1];
132
-
133
- if (typeof pluginTarget === 'string' && // TODO: use babel chain
111
+ if (typeof pluginTarget === 'string' &&
112
+ // TODO: use babel chain
134
113
  (0, _utils.slash)(pluginTarget).includes('compiled/babel-plugin-macros')) {
135
114
  if (pluginOptions) {
136
115
  pluginOptions = _objectSpread(_objectSpread({}, pluginOptions), twinConfig);
137
116
  } else {
138
117
  plugin.push(twinConfig);
139
118
  }
140
-
141
119
  return true;
142
120
  }
143
121
  }
144
-
145
122
  return false;
146
123
  });
147
124
  }
148
-
149
125
  }
150
126
  };
151
127
  }
152
-
153
128
  };
154
129
  }
155
130
  });
156
-
157
131
  exports.default = _default;
@@ -4,46 +4,37 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _utils = require("@modern-js/utils");
9
-
10
8
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
11
-
12
9
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
13
-
14
10
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
15
-
16
11
  var _default = ({
17
12
  pluginName
18
13
  } = {
19
14
  pluginName: '@modern-js/plugin-tailwindcss'
20
15
  }) => ({
21
16
  name: '@modern-js/plugin-design-token',
22
-
23
17
  setup(api) {
24
18
  let pluginsExportsUtils;
25
19
  const resolveConfig = (0, _utils.lazyImport)('tailwindcss/resolveConfig', require);
26
20
  const PLUGIN_IDENTIFIER = 'designToken';
27
-
28
21
  const getDesignTokens = userConfig => {
29
22
  var _userConfig$source;
30
-
31
23
  const designSystem = (_userConfig$source = userConfig.source) === null || _userConfig$source === void 0 ? void 0 : _userConfig$source.designSystem;
32
24
  const tailwindcssConfig = {};
33
- tailwindcssConfig.theme = designSystem ? _objectSpread({}, designSystem) : {}; // not use default design token when designToken.defaultTheme is false or theme is false
25
+ tailwindcssConfig.theme = designSystem ? _objectSpread({}, designSystem) : {};
34
26
 
27
+ // not use default design token when designToken.defaultTheme is false or theme is false
35
28
  if (!designSystem) {
36
29
  tailwindcssConfig.presets = [];
37
- } // when only designSystem exist, need remove supportStyledComponents
38
-
30
+ }
39
31
 
32
+ // when only designSystem exist, need remove supportStyledComponents
40
33
  if (designSystem) {
41
34
  delete tailwindcssConfig.theme.supportStyledComponents;
42
35
  }
43
-
44
36
  return resolveConfig(tailwindcssConfig).theme || {};
45
37
  };
46
-
47
38
  return {
48
39
  config() {
49
40
  const appContext = api.useAppContext();
@@ -54,23 +45,21 @@ var _default = ({
54
45
  '@modern-js/runtime/plugins': pluginsExportsUtils.getPath()
55
46
  }
56
47
  },
57
- tools: {// TODO: support less、scss、css vars
48
+ tools: {
49
+ // TODO: support less、scss、css vars
58
50
  // less: https://github.com/modern-js-dev/modern.js/pull/398/files#diff-f77c749e403fbf1fb676d5687bef3d7138a230331c849298d8afaff9b6afbc3dR166
59
51
  // sass: https://github.com/modern-js-dev/modern.js/pull/398/files#diff-f77c749e403fbf1fb676d5687bef3d7138a230331c849298d8afaff9b6afbc3dR229
60
52
  // postcss: https://github.com/modern-js-dev/modern.js/pull/398/files#diff-f77c749e403fbf1fb676d5687bef3d7138a230331c849298d8afaff9b6afbc3dR281
61
53
  }
62
54
  };
63
55
  },
64
-
65
56
  modifyEntryImports({
66
57
  entrypoint,
67
58
  imports
68
59
  }) {
69
60
  var _userConfig$source$de, _userConfig$source2;
70
-
71
61
  const userConfig = api.useResolvedConfigContext();
72
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 : {};
73
-
74
63
  if (typeof designSystem === 'object' && designSystem.supportStyledComponents) {
75
64
  const designTokens = getDesignTokens(userConfig);
76
65
  imports.push({
@@ -83,53 +72,42 @@ var _default = ({
83
72
  `
84
73
  });
85
74
  }
86
-
87
75
  return {
88
76
  entrypoint,
89
77
  imports
90
78
  };
91
79
  },
92
-
93
80
  modifyEntryRuntimePlugins({
94
81
  entrypoint,
95
82
  plugins
96
83
  }) {
97
84
  var _userConfig$source$de2, _userConfig$source3;
98
-
99
85
  const userConfig = api.useResolvedConfigContext();
100
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 : {};
101
87
  let useSCThemeProvider = true;
102
-
103
88
  if (designSystem) {
104
89
  // when designSystem exist, designToken.styledComponents`s default value is false.
105
90
  useSCThemeProvider = (designSystem === null || designSystem === void 0 ? void 0 : designSystem.supportStyledComponents) || false;
106
91
  }
107
-
108
92
  if (typeof designSystem === 'object' && designSystem.supportStyledComponents) {
109
93
  plugins.push({
110
94
  name: PLUGIN_IDENTIFIER,
111
95
  options: `{token: designTokens, useStyledComponentsThemeProvider: ${useSCThemeProvider ? 'true' : 'false'}, useDesignTokenContext: false}`
112
96
  });
113
97
  }
114
-
115
98
  return {
116
99
  entrypoint,
117
100
  plugins
118
101
  };
119
102
  },
120
-
121
103
  validateSchema() {
122
104
  // add source.designSystem.supportStyledComponents config
123
105
  return _utils.PLUGIN_SCHEMAS['@modern-js/plugin-design-token'];
124
106
  },
125
-
126
107
  addRuntimeExports() {
127
108
  pluginsExportsUtils.addExport(`export { default as designToken } from '${pluginName}/runtime-design-token'`);
128
109
  }
129
-
130
110
  };
131
111
  }
132
-
133
112
  });
134
-
135
113
  exports.default = _default;