@modern-js/plugin-tailwindcss 2.0.0-beta.2 → 2.0.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/CHANGELOG.md +181 -0
  2. package/dist/js/modern/cli.js +139 -84
  3. package/dist/js/modern/design-token/cli/index.js +58 -54
  4. package/dist/js/modern/design-token/global.d.js +0 -0
  5. package/dist/js/modern/design-token/index.js +5 -2
  6. package/dist/js/modern/design-token/postcss-plugin/index.js +11 -8
  7. package/dist/js/modern/design-token/runtime/index.js +4 -1
  8. package/dist/js/modern/design-token/runtime/plugin.js +41 -29
  9. package/dist/js/modern/index.js +4 -1
  10. package/dist/js/modern/modern-app.env.d.js +0 -0
  11. package/dist/js/modern/tailwind.js +30 -24
  12. package/dist/js/modern/utils.js +32 -8
  13. package/dist/js/node/cli.js +159 -95
  14. package/dist/js/node/design-token/cli/index.js +71 -59
  15. package/dist/js/node/design-token/global.d.js +0 -0
  16. package/dist/js/node/design-token/index.js +29 -24
  17. package/dist/js/node/design-token/postcss-plugin/index.js +28 -13
  18. package/dist/js/node/design-token/runtime/index.js +31 -22
  19. package/dist/js/node/design-token/runtime/plugin.js +65 -40
  20. package/dist/js/node/index.js +27 -11
  21. package/dist/js/node/modern-app.env.d.js +0 -0
  22. package/dist/js/node/tailwind.js +49 -30
  23. package/dist/js/node/utils.js +56 -16
  24. package/dist/js/treeshaking/cli.js +266 -134
  25. package/dist/js/treeshaking/design-token/cli/index.js +116 -101
  26. package/dist/js/treeshaking/design-token/global.d.js +1 -0
  27. package/dist/js/treeshaking/design-token/index.js +3 -2
  28. package/dist/js/treeshaking/design-token/postcss-plugin/index.js +17 -26
  29. package/dist/js/treeshaking/design-token/runtime/index.js +2 -1
  30. package/dist/js/treeshaking/design-token/runtime/plugin.js +76 -55
  31. package/dist/js/treeshaking/index.js +2 -1
  32. package/dist/js/treeshaking/modern-app.env.d.js +1 -0
  33. package/dist/js/treeshaking/tailwind.js +86 -43
  34. package/dist/js/treeshaking/types.js +1 -0
  35. package/dist/js/treeshaking/utils.js +159 -44
  36. package/dist/types/cli.d.ts +5 -2
  37. package/dist/types/design-token/cli/index.d.ts +2 -0
  38. package/dist/types/design-token/postcss-plugin/index.d.ts +2 -0
  39. package/dist/types/design-token/runtime/plugin.d.ts +2 -0
  40. package/dist/types/tailwind.d.ts +3 -3
  41. package/dist/types/types.d.ts +4 -10
  42. package/package.json +11 -9
@@ -1,49 +1,56 @@
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
- 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; }
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; }
4
- import hoistNonReactStatics from 'hoist-non-react-statics';
5
- import React, { useContext } from 'react';
6
- import { jsx as _jsx } from "react/jsx-runtime";
7
- export const DesignTokenContext = /*#__PURE__*/React.createContext({});
8
- export const useDesignTokens = () => useContext(DesignTokenContext);
9
- export default ((options = {}) => ({
10
- name: '@modern-js/plugin-design-token',
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __spreadValues = (a, b) => {
7
+ for (var prop in b || (b = {}))
8
+ if (__hasOwnProp.call(b, prop))
9
+ __defNormalProp(a, prop, b[prop]);
10
+ if (__getOwnPropSymbols)
11
+ for (var prop of __getOwnPropSymbols(b)) {
12
+ if (__propIsEnum.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ }
15
+ return a;
16
+ };
17
+ import { jsx } from "react/jsx-runtime";
18
+ import hoistNonReactStatics from "hoist-non-react-statics";
19
+ import React, { useContext } from "react";
20
+ const DesignTokenContext = React.createContext({});
21
+ const useDesignTokens = () => useContext(DesignTokenContext);
22
+ var plugin_default = (options = {}) => ({
23
+ name: "@modern-js/plugin-design-token",
11
24
  setup: () => ({
12
- hoc({
13
- App
14
- }, next) {
15
- const DesignTokenAppWrapper = props => {
25
+ hoc({ App }, next) {
26
+ const DesignTokenAppWrapper = (props) => {
16
27
  const {
17
28
  token = {},
18
29
  useStyledComponentsThemeProvider = false,
19
30
  useDesignTokenContext = false
20
31
  } = options;
21
32
  if (useStyledComponentsThemeProvider && useDesignTokenContext) {
22
- const {
23
- ThemeProvider
24
- } = require('@modern-js/runtime/styled');
25
- return /*#__PURE__*/_jsx(ThemeProvider, {
33
+ const { ThemeProvider } = require("@modern-js/runtime/styled");
34
+ return /* @__PURE__ */ jsx(ThemeProvider, {
26
35
  theme: token,
27
- children: /*#__PURE__*/_jsx(DesignTokenContext.Provider, {
36
+ children: /* @__PURE__ */ jsx(DesignTokenContext.Provider, {
28
37
  value: token,
29
- children: /*#__PURE__*/_jsx(App, _objectSpread({}, props))
38
+ children: /* @__PURE__ */ jsx(App, __spreadValues({}, props))
30
39
  })
31
40
  });
32
41
  } else if (useStyledComponentsThemeProvider) {
33
- const {
34
- ThemeProvider
35
- } = require('@modern-js/runtime/styled');
36
- return /*#__PURE__*/_jsx(ThemeProvider, {
42
+ const { ThemeProvider } = require("@modern-js/runtime/styled");
43
+ return /* @__PURE__ */ jsx(ThemeProvider, {
37
44
  theme: token,
38
- children: /*#__PURE__*/_jsx(App, _objectSpread({}, props))
45
+ children: /* @__PURE__ */ jsx(App, __spreadValues({}, props))
39
46
  });
40
47
  } else if (useDesignTokenContext) {
41
- return /*#__PURE__*/_jsx(DesignTokenContext.Provider, {
48
+ return /* @__PURE__ */ jsx(DesignTokenContext.Provider, {
42
49
  value: token,
43
- children: /*#__PURE__*/_jsx(App, _objectSpread({}, props))
50
+ children: /* @__PURE__ */ jsx(App, __spreadValues({}, props))
44
51
  });
45
52
  } else {
46
- return /*#__PURE__*/_jsx(App, _objectSpread({}, props));
53
+ return /* @__PURE__ */ jsx(App, __spreadValues({}, props));
47
54
  }
48
55
  };
49
56
  return next({
@@ -51,4 +58,9 @@ export default ((options = {}) => ({
51
58
  });
52
59
  }
53
60
  })
54
- }));
61
+ });
62
+ export {
63
+ DesignTokenContext,
64
+ plugin_default as default,
65
+ useDesignTokens
66
+ };
@@ -1 +1,4 @@
1
- export { default } from "./cli";
1
+ import { default as default2 } from "./cli";
2
+ export {
3
+ default2 as default
4
+ };
File without changes
@@ -1,39 +1,45 @@
1
- import { applyOptionsChain, logger } from '@modern-js/utils';
2
- import { merge, cloneDeep } from '@modern-js/utils/lodash';
3
- const checkIfExistNotAllowKeys = tailwindConfig => {
4
- const notAllowExistKeys = ['theme'];
5
- let notAllowKey = '';
6
- const ret = Object.keys(tailwindConfig).some(key => notAllowExistKeys.includes(key) && (notAllowKey = key));
1
+ import { applyOptionsChain, logger } from "@modern-js/utils";
2
+ import { merge, cloneDeep } from "@modern-js/utils/lodash";
3
+ const checkIfExistNotAllowKeys = (tailwindConfig) => {
4
+ const notAllowExistKeys = ["theme"];
5
+ let notAllowKey = "";
6
+ const ret = Object.keys(tailwindConfig).some(
7
+ (key) => notAllowExistKeys.includes(key) && (notAllowKey = key)
8
+ );
7
9
  return [ret, notAllowKey];
8
10
  };
9
- const getPureDesignSystemConfig = designSystemConfig => {
11
+ const getPureDesignSystemConfig = (designSystemConfig) => {
10
12
  const pureDesignSystemConfig = cloneDeep(designSystemConfig);
11
13
  delete pureDesignSystemConfig.supportStyledComponents;
12
14
  return pureDesignSystemConfig;
13
15
  };
14
- const getTailwindConfig = (config, option = {}) => {
15
- var _config$tools, _ref, _designSystem;
16
- const purgeConfig = merge({
17
- // TODO: how the operating environment is determined
18
- enabled: process.env.NODE_ENV === 'production',
19
- // TODO: Remove or not
20
- layers: ['utilities'],
21
- content: []
22
- }, option.pureConfig || {});
16
+ const getTailwindConfig = (tailwindcss, designSystem, option = {}) => {
17
+ const purgeConfig = merge(
18
+ {
19
+ enabled: process.env.NODE_ENV === "production",
20
+ layers: ["utilities"],
21
+ content: []
22
+ },
23
+ option.pureConfig || {}
24
+ );
23
25
  const defaultTailwindConfig = {
24
26
  purge: purgeConfig
25
27
  };
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 : {});
28
+ const tailwindConfig = applyOptionsChain(
29
+ defaultTailwindConfig,
30
+ tailwindcss || {}
31
+ );
32
+ const designSystemConfig = getPureDesignSystemConfig(designSystem != null ? designSystem : {});
28
33
  const [exist, key] = checkIfExistNotAllowKeys(tailwindConfig);
29
34
  if (exist) {
30
- logger.error(`should not exist '${key}' on tools.tailwindcss, please remove it`);
31
- // eslint-disable-next-line no-process-exit
35
+ logger.error(
36
+ `should not exist '${key}' on tools.tailwindcss, please remove it`
37
+ );
32
38
  process.exit(0);
33
39
  }
34
-
35
- // Because there is no default theme configuration
36
- tailwindConfig.theme = designSystem || {};
40
+ tailwindConfig.theme = designSystemConfig || {};
37
41
  return tailwindConfig;
38
42
  };
39
- export { getTailwindConfig };
43
+ export {
44
+ getTailwindConfig
45
+ };
@@ -1,6 +1,26 @@
1
- import path from 'path';
2
- import { fs } from '@modern-js/utils';
3
- export const template = configPath => `
1
+ var __async = (__this, __arguments, generator) => {
2
+ return new Promise((resolve, reject) => {
3
+ var fulfilled = (value) => {
4
+ try {
5
+ step(generator.next(value));
6
+ } catch (e) {
7
+ reject(e);
8
+ }
9
+ };
10
+ var rejected = (value) => {
11
+ try {
12
+ step(generator.throw(value));
13
+ } catch (e) {
14
+ reject(e);
15
+ }
16
+ };
17
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
18
+ step((generator = generator.apply(__this, __arguments)).next());
19
+ });
20
+ };
21
+ import path from "path";
22
+ import { fs } from "@modern-js/utils";
23
+ const template = (configPath) => `
4
24
  function _interopRequireDefault(obj) {
5
25
  return obj && obj.__esModule ? obj : { default: obj };
6
26
  }
@@ -20,13 +40,17 @@ module.exports = {
20
40
  ...tailwindcss,
21
41
  };
22
42
  `;
23
- export const checkTwinMacroNotExist = async appDirectory => {
24
- const depName = 'twin.macro';
25
- const packageJson = (await fs.readJSON(path.join(appDirectory, 'package.json'), {
43
+ const checkTwinMacroNotExist = (appDirectory) => __async(void 0, null, function* () {
44
+ const depName = "twin.macro";
45
+ const packageJson = (yield fs.readJSON(path.join(appDirectory, "package.json"), {
26
46
  throws: false
27
47
  })) || {};
28
- if (typeof packageJson.dependencies === 'object' && packageJson.dependencies[depName] || typeof packageJson.devDependencies === 'object' && packageJson.devDependencies[depName]) {
48
+ if (typeof packageJson.dependencies === "object" && packageJson.dependencies[depName] || typeof packageJson.devDependencies === "object" && packageJson.devDependencies[depName]) {
29
49
  return false;
30
50
  }
31
51
  return true;
32
- };
52
+ });
53
+ export {
54
+ checkTwinMacroNotExist,
55
+ template
56
+ };
@@ -1,131 +1,195 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
+ mod
22
+ ));
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
5
28
  });
6
- exports.getRandomTwConfigFileName = exports.default = void 0;
7
- var _path = _interopRequireDefault(require("path"));
8
- var _utils = require("@modern-js/utils");
9
- var _cli = _interopRequireDefault(require("./design-token/cli"));
10
- var _tailwind = require("./tailwind");
11
- var _utils2 = require("./utils");
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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; }
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; }
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; }
16
- const supportCssInJsLibrary = 'styled-components';
17
- const getRandomTwConfigFileName = internalDirectory => {
18
- return (0, _utils.slash)(_path.default.join(internalDirectory, `tailwind.config.${Date.now()}.${(0, _utils.nanoid)()}.js`));
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
+ var __async = (__this, __arguments, generator) => {
36
+ return new Promise((resolve, reject) => {
37
+ var fulfilled = (value) => {
38
+ try {
39
+ step(generator.next(value));
40
+ } catch (e) {
41
+ reject(e);
42
+ }
43
+ };
44
+ var rejected = (value) => {
45
+ try {
46
+ step(generator.throw(value));
47
+ } catch (e) {
48
+ reject(e);
49
+ }
50
+ };
51
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
52
+ step((generator = generator.apply(__this, __arguments)).next());
53
+ });
54
+ };
55
+ const supportCssInJsLibrary = "styled-components";
56
+ const getRandomTwConfigFileName = (internalDirectory) => {
57
+ return (0, import_utils.slash)(
58
+ import_path.default.join(
59
+ internalDirectory,
60
+ `tailwind.config.${Date.now()}.${(0, import_utils.nanoid)()}.js`
61
+ )
62
+ );
19
63
  };
20
- exports.getRandomTwConfigFileName = getRandomTwConfigFileName;
21
- var _default = ({
22
- pluginName
23
- } = {
24
- pluginName: '@modern-js/plugin-tailwindcss'
64
+ var cli_default = ({ pluginName } = {
65
+ pluginName: "@modern-js/plugin-tailwindcss"
25
66
  }) => ({
26
- name: '@modern-js/plugin-tailwindcss',
27
- // support designSystem.supportStyledComponents
28
- usePlugins: [(0, _cli.default)({
29
- pluginName
30
- })],
31
- setup: async api => {
32
- const {
33
- appDirectory,
34
- internalDirectory
35
- } = api.useAppContext();
36
- let internalTwConfigPath = '';
37
- // When reinstalling dependencies, most of the time the project will be restarted
38
- const notHaveTwinMacro = await (0, _utils2.checkTwinMacroNotExist)(appDirectory);
67
+ name: "@modern-js/plugin-tailwindcss",
68
+ usePlugins: [
69
+ (0, import_cli.default)({
70
+ pluginName
71
+ })
72
+ ],
73
+ setup: (api) => __async(void 0, null, function* () {
74
+ const { appDirectory, internalDirectory } = api.useAppContext();
75
+ let internalTwConfigPath = "";
76
+ const notHaveTwinMacro = yield (0, import_utils2.checkTwinMacroNotExist)(appDirectory);
39
77
  return {
40
78
  prepare() {
41
79
  if (notHaveTwinMacro) {
42
80
  return;
43
81
  }
44
82
  internalTwConfigPath = getRandomTwConfigFileName(internalDirectory);
45
- const globPattern = (0, _utils.slash)(_path.default.join(appDirectory, _utils.CONFIG_CACHE_DIR, '*.cjs'));
46
- const files = _utils.globby.sync(globPattern, {
83
+ const globPattern = (0, import_utils.slash)(
84
+ import_path.default.join(appDirectory, import_utils.CONFIG_CACHE_DIR, "*.cjs")
85
+ );
86
+ const files = import_utils.globby.sync(globPattern, {
47
87
  absolute: true
48
88
  });
49
89
  if (files.length > 0) {
50
- _utils.fs.writeFileSync(internalTwConfigPath, (0, _utils2.template)(files[files.length - 1]), 'utf-8');
90
+ import_utils.fs.writeFileSync(
91
+ internalTwConfigPath,
92
+ (0, import_utils2.template)(files[files.length - 1]),
93
+ "utf-8"
94
+ );
51
95
  }
52
96
  },
53
97
  validateSchema() {
54
- return _utils.PLUGIN_SCHEMAS['@modern-js/plugin-tailwindcss'];
98
+ return import_utils.PLUGIN_SCHEMAS["@modern-js/plugin-tailwindcss"];
55
99
  },
56
100
  config() {
57
101
  return {
58
102
  tools: {
59
- // TODO: Add interface about postcss config
60
- // TODO: In module project, also is called, but should not be called.
61
- postcss: config => {
103
+ postcss: (config) => {
104
+ var _a, _b;
62
105
  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)];
80
- }
81
- } else {
82
- const tailwindConfig = (0, _tailwind.getTailwindConfig)(modernConfig, {
106
+ const tailwindConfig = (0, import_tailwind.getTailwindConfig)(
107
+ (_a = modernConfig == null ? void 0 : modernConfig.tools) == null ? void 0 : _a.tailwindcss,
108
+ (_b = modernConfig == null ? void 0 : modernConfig.source) == null ? void 0 : _b.designSystem,
109
+ {
83
110
  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']
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
+ ]
87
125
  }
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
126
  }
127
+ );
128
+ if (Array.isArray(config.postcssOptions.plugins)) {
129
+ config.postcssOptions.plugins.push(
130
+ require("tailwindcss")(tailwindConfig)
131
+ );
132
+ } else {
133
+ config.postcssOptions.plugins = [
134
+ require("tailwindcss")(tailwindConfig)
135
+ ];
94
136
  }
95
137
  },
96
- babel(config) {
97
- var _config$plugins;
138
+ babel(_, { addPlugins }) {
98
139
  if (notHaveTwinMacro) {
99
140
  return;
100
141
  }
101
- const twinConfig = {
102
- twin: {
103
- preset: supportCssInJsLibrary,
104
- config: internalTwConfigPath
105
- }
106
- };
107
- (_config$plugins = config.plugins) === null || _config$plugins === void 0 ? void 0 : _config$plugins.some(plugin => {
108
- if (Array.isArray(plugin) && plugin[0]) {
109
- const pluginTarget = plugin[0];
110
- let pluginOptions = plugin[1];
111
- if (typeof pluginTarget === 'string' &&
112
- // TODO: use babel chain
113
- (0, _utils.slash)(pluginTarget).includes('compiled/babel-plugin-macros')) {
114
- if (pluginOptions) {
115
- pluginOptions = _objectSpread(_objectSpread({}, pluginOptions), twinConfig);
116
- } else {
117
- plugin.push(twinConfig);
142
+ addPlugins([
143
+ [
144
+ require.resolve("babel-plugin-macros"),
145
+ {
146
+ twin: {
147
+ preset: supportCssInJsLibrary,
148
+ config: internalTwConfigPath
118
149
  }
119
- return true;
120
150
  }
121
- }
122
- return false;
123
- });
151
+ ]
152
+ ]);
124
153
  }
125
154
  }
126
155
  };
156
+ },
157
+ beforeBuildTask({ config }) {
158
+ const modernConfig = api.useResolvedConfigContext();
159
+ const { designSystem } = modernConfig;
160
+ const tailwindConfig = (0, import_tailwind.getTailwindConfig)(
161
+ config.style.tailwindCss,
162
+ designSystem,
163
+ {
164
+ 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
+ ]
179
+ }
180
+ }
181
+ );
182
+ if (Array.isArray(config.style.postcss.plugins)) {
183
+ config.style.postcss.plugins.push(
184
+ require("tailwindcss")(tailwindConfig)
185
+ );
186
+ } else {
187
+ config.style.postcss.plugins = [
188
+ require("tailwindcss")(tailwindConfig)
189
+ ];
190
+ }
191
+ return config;
127
192
  }
128
193
  };
129
- }
194
+ })
130
195
  });
131
- exports.default = _default;