@modern-js/plugin-tailwindcss 2.0.0-beta.3 → 2.0.0-beta.6

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 (41) hide show
  1. package/CHANGELOG.md +197 -0
  2. package/dist/js/modern/cli.js +132 -79
  3. package/dist/js/modern/design-token/cli/index.js +57 -51
  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 +28 -21
  12. package/dist/js/modern/utils.js +32 -8
  13. package/dist/js/node/cli.js +156 -90
  14. package/dist/js/node/design-token/cli/index.js +70 -56
  15. package/dist/js/node/design-token/global.d.js +0 -0
  16. package/dist/js/node/design-token/index.js +31 -24
  17. package/dist/js/node/design-token/postcss-plugin/index.js +30 -13
  18. package/dist/js/node/design-token/runtime/index.js +33 -22
  19. package/dist/js/node/design-token/runtime/plugin.js +68 -40
  20. package/dist/js/node/index.js +29 -11
  21. package/dist/js/node/modern-app.env.d.js +0 -0
  22. package/dist/js/node/tailwind.js +51 -27
  23. package/dist/js/node/types.js +15 -0
  24. package/dist/js/node/utils.js +61 -16
  25. package/dist/js/treeshaking/cli.js +265 -132
  26. package/dist/js/treeshaking/design-token/cli/index.js +116 -99
  27. package/dist/js/treeshaking/design-token/global.d.js +1 -0
  28. package/dist/js/treeshaking/design-token/index.js +3 -2
  29. package/dist/js/treeshaking/design-token/postcss-plugin/index.js +17 -26
  30. package/dist/js/treeshaking/design-token/runtime/index.js +2 -1
  31. package/dist/js/treeshaking/design-token/runtime/plugin.js +76 -55
  32. package/dist/js/treeshaking/index.js +2 -1
  33. package/dist/js/treeshaking/modern-app.env.d.js +1 -0
  34. package/dist/js/treeshaking/tailwind.js +86 -42
  35. package/dist/js/treeshaking/types.js +1 -0
  36. package/dist/js/treeshaking/utils.js +159 -44
  37. package/dist/types/cli.d.ts +3 -1
  38. package/dist/types/design-token/cli/index.d.ts +2 -0
  39. package/dist/types/design-token/postcss-plugin/index.d.ts +2 -0
  40. package/dist/types/design-token/runtime/plugin.d.ts +2 -0
  41. package/package.json +11 -10
@@ -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,38 +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
16
  const getTailwindConfig = (tailwindcss, designSystem, option = {}) => {
15
- const purgeConfig = merge({
16
- // TODO: how the operating environment is determined
17
- enabled: process.env.NODE_ENV === 'production',
18
- // TODO: Remove or not
19
- layers: ['utilities'],
20
- content: []
21
- }, option.pureConfig || {});
17
+ const purgeConfig = merge(
18
+ {
19
+ enabled: process.env.NODE_ENV === "production",
20
+ layers: ["utilities"],
21
+ content: []
22
+ },
23
+ option.pureConfig || {}
24
+ );
22
25
  const defaultTailwindConfig = {
23
26
  purge: purgeConfig
24
27
  };
25
- const tailwindConfig = applyOptionsChain(defaultTailwindConfig, tailwindcss || {});
26
- const designSystemConfig = getPureDesignSystemConfig(designSystem !== null && designSystem !== void 0 ? designSystem : {});
28
+ const tailwindConfig = applyOptionsChain(
29
+ defaultTailwindConfig,
30
+ tailwindcss || {}
31
+ );
32
+ const designSystemConfig = getPureDesignSystemConfig(designSystem != null ? designSystem : {});
27
33
  const [exist, key] = checkIfExistNotAllowKeys(tailwindConfig);
28
34
  if (exist) {
29
- logger.error(`should not exist '${key}' on tools.tailwindcss, please remove it`);
30
- // eslint-disable-next-line no-process-exit
35
+ logger.error(
36
+ `should not exist '${key}' on tools.tailwindcss, please remove it`
37
+ );
31
38
  process.exit(0);
32
39
  }
33
-
34
- // Because there is no default theme configuration
35
40
  tailwindConfig.theme = designSystemConfig || {};
36
41
  return tailwindConfig;
37
42
  };
38
- 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,133 +1,199 @@
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 __async = (__this, __arguments, generator) => {
25
+ return new Promise((resolve, reject) => {
26
+ var fulfilled = (value) => {
27
+ try {
28
+ step(generator.next(value));
29
+ } catch (e) {
30
+ reject(e);
31
+ }
32
+ };
33
+ var rejected = (value) => {
34
+ try {
35
+ step(generator.throw(value));
36
+ } catch (e) {
37
+ reject(e);
38
+ }
39
+ };
40
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
41
+ step((generator = generator.apply(__this, __arguments)).next());
42
+ });
43
+ };
44
+ var cli_exports = {};
45
+ __export(cli_exports, {
46
+ default: () => cli_default,
47
+ getRandomTwConfigFileName: () => getRandomTwConfigFileName
5
48
  });
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`));
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
+ 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 => {
62
- var _modernConfig$tools, _modernConfig$source;
103
+ postcss: (config) => {
104
+ var _a, _b;
63
105
  const modernConfig = api.useResolvedConfigContext();
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']
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
+ {
110
+ 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
+ ]
125
+ }
69
126
  }
70
- });
127
+ );
71
128
  if (Array.isArray(config.postcssOptions.plugins)) {
72
- config.postcssOptions.plugins.push(require('tailwindcss')(tailwindConfig));
129
+ config.postcssOptions.plugins.push(
130
+ require("tailwindcss")(tailwindConfig)
131
+ );
73
132
  } else {
74
- config.postcssOptions.plugins = [require('tailwindcss')(tailwindConfig)];
133
+ config.postcssOptions.plugins = [
134
+ require("tailwindcss")(tailwindConfig)
135
+ ];
75
136
  }
76
137
  },
77
- babel(config) {
78
- var _config$plugins;
138
+ babel(_, { addPlugins }) {
79
139
  if (notHaveTwinMacro) {
80
140
  return;
81
141
  }
82
- const twinConfig = {
83
- twin: {
84
- preset: supportCssInJsLibrary,
85
- config: internalTwConfigPath
86
- }
87
- };
88
- (_config$plugins = config.plugins) === null || _config$plugins === void 0 ? void 0 : _config$plugins.some(plugin => {
89
- if (Array.isArray(plugin) && plugin[0]) {
90
- const pluginTarget = plugin[0];
91
- let pluginOptions = plugin[1];
92
- if (typeof pluginTarget === 'string' &&
93
- // TODO: use babel chain
94
- (0, _utils.slash)(pluginTarget).includes('compiled/babel-plugin-macros')) {
95
- if (pluginOptions) {
96
- pluginOptions = _objectSpread(_objectSpread({}, pluginOptions), twinConfig);
97
- } else {
98
- plugin.push(twinConfig);
142
+ addPlugins([
143
+ [
144
+ require.resolve("babel-plugin-macros"),
145
+ {
146
+ twin: {
147
+ preset: supportCssInJsLibrary,
148
+ config: internalTwConfigPath
99
149
  }
100
- return true;
101
150
  }
102
- }
103
- return false;
104
- });
151
+ ]
152
+ ]);
105
153
  }
106
154
  }
107
155
  };
108
156
  },
109
- beforeBuildTask({
110
- config
111
- }) {
157
+ beforeBuildTask({ config }) {
112
158
  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']
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
+ }
121
180
  }
122
- });
181
+ );
123
182
  if (Array.isArray(config.style.postcss.plugins)) {
124
- config.style.postcss.plugins.push(require('tailwindcss')(tailwindConfig));
183
+ config.style.postcss.plugins.push(
184
+ require("tailwindcss")(tailwindConfig)
185
+ );
125
186
  } else {
126
- config.style.postcss.plugins = [require('tailwindcss')(tailwindConfig)];
187
+ config.style.postcss.plugins = [
188
+ require("tailwindcss")(tailwindConfig)
189
+ ];
127
190
  }
128
191
  return config;
129
192
  }
130
193
  };
131
- }
194
+ })
195
+ });
196
+ // Annotate the CommonJS export names for ESM import in node:
197
+ 0 && (module.exports = {
198
+ getRandomTwConfigFileName
132
199
  });
133
- exports.default = _default;