@umijs/plugins 4.6.62 → 4.6.64

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 (2) hide show
  1. package/dist/tailwindcss.js +79 -15
  2. package/package.json +4 -3
@@ -39,11 +39,55 @@ var tailwindcss_default = (api) => {
39
39
  });
40
40
  let tailwind = null;
41
41
  const outputPath = "plugin-tailwindcss/tailwind.css";
42
+ api.modifyConfig((memo) => {
43
+ var _a, _b, _c;
44
+ if (!memo.utoopack || !isTailwindV4({ cwd: api.cwd })) {
45
+ return memo;
46
+ }
47
+ const ruleKey = "*.css";
48
+ return {
49
+ ...memo,
50
+ utoopack: {
51
+ ...memo.utoopack,
52
+ module: {
53
+ ...(_a = memo.utoopack) == null ? void 0 : _a.module,
54
+ rules: {
55
+ [ruleKey]: {
56
+ condition: {
57
+ path: /(^|[\\\/])tailwind\.css$/
58
+ },
59
+ loaders: [
60
+ {
61
+ loader: getTailwindWebpackLoaderPath({ cwd: api.cwd }, api),
62
+ options: {
63
+ base: api.cwd
64
+ }
65
+ }
66
+ ],
67
+ as: "*.css"
68
+ },
69
+ ...(_c = (_b = memo.utoopack) == null ? void 0 : _b.module) == null ? void 0 : _c.rules
70
+ }
71
+ }
72
+ }
73
+ };
74
+ });
75
+ api.chainWebpack((memo) => {
76
+ if (!shouldUseTailwindWebpackLoader(api)) {
77
+ return;
78
+ }
79
+ memo.module.rule("tailwindcss").enforce("pre").test(/(^|[\\\/])tailwind\.css$/).use("tailwindcss-loader").loader(getTailwindWebpackLoaderPath({ cwd: api.cwd }, api)).options({
80
+ base: api.cwd
81
+ });
82
+ });
42
83
  api.onBeforeCompiler(() => {
43
84
  const inputPath = (0, import_path.join)(api.cwd, "tailwind.css");
44
85
  const generatedPath = (0, import_path.join)(api.paths.absTmpPath, outputPath);
45
- const binPath = getTailwindBinPath({ cwd: api.cwd }, api);
46
86
  const configPath = (0, import_path.join)(api.cwd, "tailwind.config.js");
87
+ if (isTailwindV4({ cwd: api.cwd })) {
88
+ return;
89
+ }
90
+ const binPath = getTailwindBinPath({ cwd: api.cwd });
47
91
  if (process.env.IS_UMI_BUILD_WORKER) {
48
92
  return;
49
93
  }
@@ -93,29 +137,49 @@ var tailwindcss_default = (api) => {
93
137
  });
94
138
  });
95
139
  api.addEntryImports(() => {
140
+ if (isTailwindV4({ cwd: api.cwd })) {
141
+ return [{ source: (0, import_plugin_utils.winPath)((0, import_path.join)(api.cwd, "tailwind.css")) }];
142
+ }
96
143
  const generatedPath = (0, import_plugin_utils.winPath)((0, import_path.join)(api.paths.absTmpPath, outputPath));
97
144
  return [{ source: generatedPath }];
98
145
  });
99
146
  };
100
- function getTailwindBinPath(opts, api) {
147
+ function isTailwindV4(opts) {
101
148
  const pkgPath = require.resolve("tailwindcss/package.json", {
102
149
  paths: [opts.cwd]
103
150
  });
104
151
  const tailwind = require(pkgPath);
105
- if (tailwind.version.startsWith("4")) {
106
- try {
107
- const tailwindCliPath = require.resolve("@tailwindcss/cli/package.json", {
108
- paths: [opts.cwd]
109
- });
110
- const tailwindPath2 = require(tailwindCliPath).bin["tailwindcss"];
111
- return (0, import_path.join)((0, import_path.dirname)(tailwindCliPath), tailwindPath2);
112
- } catch {
113
- api.logger.error(
114
- "tailwindcss v4 requires @tailwindcss/cli to be installed"
115
- );
116
- process.exit(1);
117
- }
152
+ return tailwind.version.startsWith("4");
153
+ }
154
+ function shouldUseTailwindWebpackLoader(api) {
155
+ if (!isTailwindV4({ cwd: api.cwd })) {
156
+ return false;
118
157
  }
158
+ return Boolean(!api.config.utoopack && !api.config.vite && !api.config.mako);
159
+ }
160
+ function getTailwindBinPath(opts) {
161
+ const pkgPath = require.resolve("tailwindcss/package.json", {
162
+ paths: [opts.cwd]
163
+ });
119
164
  const tailwindPath = require(pkgPath).bin["tailwind"];
120
165
  return (0, import_path.join)((0, import_path.dirname)(pkgPath), tailwindPath);
121
166
  }
167
+ function getTailwindWebpackLoaderPath(opts, api) {
168
+ for (const cwd of [__dirname, opts.cwd]) {
169
+ const loaderPath = tryResolveTailwindWebpackLoader(cwd);
170
+ if (loaderPath) return loaderPath;
171
+ }
172
+ api.logger.error(
173
+ "tailwindcss v4 with webpack or utoopack requires @tailwindcss/webpack"
174
+ );
175
+ process.exit(1);
176
+ }
177
+ function tryResolveTailwindWebpackLoader(cwd) {
178
+ try {
179
+ return require.resolve("@tailwindcss/webpack", {
180
+ paths: [cwd]
181
+ });
182
+ } catch {
183
+ return null;
184
+ }
185
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/plugins",
3
- "version": "4.6.62",
3
+ "version": "4.6.64",
4
4
  "description": "@umijs/plugins",
5
5
  "homepage": "https://github.com/umijs/umi/tree/master/packages/plugins#readme",
6
6
  "bugs": "https://github.com/umijs/umi/issues",
@@ -23,6 +23,7 @@
23
23
  "@ant-design/icons": "^4.7.0",
24
24
  "@ant-design/moment-webpack-plugin": "^0.0.3",
25
25
  "@ant-design/pro-components": "^2.0.1",
26
+ "@tailwindcss/webpack": "^4.3.1",
26
27
  "@tanstack/react-query": "^4.24.10",
27
28
  "@tanstack/react-query-devtools": "^4.24.10",
28
29
  "antd-dayjs-webpack-plugin": "^1.0.6",
@@ -45,12 +46,12 @@
45
46
  "styled-components": "6.1.1",
46
47
  "tslib": "^2",
47
48
  "warning": "^4.0.3",
48
- "@umijs/bundler-utils": "4.6.62",
49
+ "@umijs/bundler-utils": "4.6.64",
49
50
  "@umijs/valtio": "1.0.4"
50
51
  },
51
52
  "devDependencies": {
52
53
  "antd": "^4.24.1",
53
- "umi": "4.6.62"
54
+ "umi": "4.6.64"
54
55
  },
55
56
  "publishConfig": {
56
57
  "access": "public"