weapp-tailwindcss 5.1.7 → 5.1.8
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/dist/bundlers/framework-selector.d.ts +26 -0
- package/dist/bundlers/gulp/frameworks/native/index.d.ts +6 -0
- package/dist/bundlers/gulp/index.d.ts +4 -4
- package/dist/bundlers/gulp/shared/create-native-framework-plugins.d.ts +6 -0
- package/dist/bundlers/vite/css-finalizer.d.ts +2 -0
- package/dist/bundlers/vite/frameworks/generic/index.d.ts +2 -0
- package/dist/bundlers/vite/frameworks/taro/index.d.ts +2 -0
- package/dist/bundlers/vite/frameworks/uni-app/index.d.ts +2 -0
- package/dist/bundlers/vite/frameworks/uni-app-x/index.d.ts +2 -0
- package/dist/bundlers/vite/frameworks/weapp-vite/index.d.ts +2 -0
- package/dist/bundlers/vite/generate-bundle/css-output-helpers.d.ts +5 -1
- package/dist/bundlers/vite/generate-bundle/finalize.d.ts +5 -1
- package/dist/bundlers/vite/generate-bundle/root-style-output.d.ts +2 -2
- package/dist/bundlers/vite/generate-bundle/sfc-style-source.d.ts +8 -0
- package/dist/bundlers/vite/generate-bundle/types.d.ts +2 -0
- package/dist/bundlers/vite/index.d.ts +2 -4
- package/dist/bundlers/vite/processed-css-assets.d.ts +5 -0
- package/dist/bundlers/vite/shared/create-framework-plugins.d.ts +35 -0
- package/dist/bundlers/vite/shared/framework-strategy.d.ts +88 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +1 -2
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers.d.ts +1 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +3 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +1 -2
- package/dist/bundlers/webpack/frameworks/generic/index.d.ts +5 -0
- package/dist/bundlers/webpack/frameworks/index.d.ts +8 -0
- package/dist/bundlers/webpack/frameworks/mpx/index.d.ts +5 -0
- package/dist/bundlers/webpack/frameworks/taro/index.d.ts +5 -0
- package/dist/bundlers/webpack/frameworks/uni-app/index.d.ts +5 -0
- package/dist/bundlers/webpack/frameworks/weapp-vite/index.d.ts +5 -0
- package/dist/bundlers/webpack/shared/create-framework-plugin.d.ts +21 -0
- package/dist/bundlers/webpack/shared/loader-anchors.d.ts +4 -3
- package/dist/cli.js +8 -0
- package/dist/cli.mjs +8 -0
- package/dist/{context-C7KTDlrG.js → context-CRhUs_5e.js} +11 -3
- package/dist/{context-BqeDu1Ha.mjs → context-CfXr3hWz.mjs} +11 -3
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/{generator-DASZwC6t.js → generator-DaaFxR5V.js} +1 -1
- package/dist/{generator-BOt2Tvx3.mjs → generator-DugIHBgl.mjs} +1 -1
- package/dist/generator.js +2 -2
- package/dist/generator.mjs +2 -2
- package/dist/{gulp-alDZryyB.mjs → gulp-CRjkPsbX.mjs} +22 -7
- package/dist/{gulp-D6hsaTLM.js → gulp-JUfnhOOo.js} +22 -7
- package/dist/gulp.js +1 -1
- package/dist/gulp.mjs +1 -1
- package/dist/{hmr-timing-CYwVMRol.mjs → hmr-timing-BecOXMd8.mjs} +5 -5
- package/dist/{hmr-timing-BIr_CiPW.js → hmr-timing-DcIEXnf8.js} +5 -5
- package/dist/index.js +4 -4
- package/dist/index.mjs +4 -4
- package/dist/postcss.js +2 -2
- package/dist/postcss.mjs +2 -2
- package/dist/presets.js +2 -2
- package/dist/presets.mjs +2 -2
- package/dist/rspack.js +1 -1
- package/dist/rspack.mjs +1 -1
- package/dist/{source-candidate-scan-signature-Djr2Hw8y.js → source-candidate-scan-signature-10tvdJVC.js} +185 -98
- package/dist/{source-candidate-scan-signature-D97ZEXcj.mjs → source-candidate-scan-signature-DAg8QSgh.mjs} +162 -99
- package/dist/style-injector/internal.d.ts +18 -4
- package/dist/{tailwindcss-DPxJpRVP.js → tailwindcss-BZjZZi60.js} +1 -1
- package/dist/{tailwindcss-DDGD90w7.mjs → tailwindcss-PA2jHHpx.mjs} +1 -1
- package/dist/{transform-CvqqZBuq.js → transform-B0BxX3XB.js} +1 -1
- package/dist/{transform-DPPr79r2.mjs → transform-wNEbcZeQ.mjs} +1 -1
- package/dist/uni-app-x/vite.d.ts +1 -0
- package/dist/{v4-engine-3UmJkAY7.js → v4-engine-BZP2462H.js} +12 -0
- package/dist/{v4-engine-CYSrDVNp.mjs → v4-engine-CjjWONB0.mjs} +12 -0
- package/dist/{vite-BJRlG835.js → vite-GdzlG_lx.js} +1286 -818
- package/dist/{vite-XxJh7Xtu.mjs → vite-vf2-cDdk.mjs} +1284 -816
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.js +21 -1
- package/dist/{webpack-eN8WzIT-.mjs → webpack-2s-TFhgm.mjs} +321 -216
- package/dist/{webpack-BxBOMUtY.js → webpack-BhM4Hqla.js} +320 -215
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +3 -3
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-emK7D4bc.js");
|
|
2
|
-
const require_v4_engine = require("./v4-engine-
|
|
3
|
-
const require_generator = require("./generator-
|
|
2
|
+
const require_v4_engine = require("./v4-engine-BZP2462H.js");
|
|
3
|
+
const require_generator = require("./generator-DaaFxR5V.js");
|
|
4
4
|
const require_utils = require("./utils-D3h8j7Mk.js");
|
|
5
|
-
const require_context = require("./context-
|
|
6
|
-
const require_tailwindcss = require("./tailwindcss-
|
|
7
|
-
const require_hmr_timing = require("./hmr-timing-
|
|
8
|
-
const require_source_candidate_scan_signature = require("./source-candidate-scan-signature-
|
|
5
|
+
const require_context = require("./context-CRhUs_5e.js");
|
|
6
|
+
const require_tailwindcss = require("./tailwindcss-BZjZZi60.js");
|
|
7
|
+
const require_hmr_timing = require("./hmr-timing-DcIEXnf8.js");
|
|
8
|
+
const require_source_candidate_scan_signature = require("./source-candidate-scan-signature-10tvdJVC.js");
|
|
9
9
|
let node_fs = require("node:fs");
|
|
10
10
|
node_fs = require_rolldown_runtime.__toESM(node_fs);
|
|
11
11
|
let node_path = require("node:path");
|
|
@@ -20,188 +20,7 @@ let node_module = require("node:module");
|
|
|
20
20
|
node_module = require_rolldown_runtime.__toESM(node_module);
|
|
21
21
|
let _weapp_core_escape = require("@weapp-core/escape");
|
|
22
22
|
let _weapp_tailwindcss_shared_node = require("@weapp-tailwindcss/shared/node");
|
|
23
|
-
//#region src/shared/tailwindcss-css-redirect.ts
|
|
24
|
-
const moduleWithMutableResolve = node_module.default;
|
|
25
|
-
const patched = /* @__PURE__ */ new WeakSet();
|
|
26
|
-
function installTailwindcssCssRedirect(pkgDir) {
|
|
27
|
-
const target = node_path.default.join(pkgDir, "index.css");
|
|
28
|
-
const original = moduleWithMutableResolve._resolveFilename;
|
|
29
|
-
if (patched.has(original)) return;
|
|
30
|
-
const replacements = /* @__PURE__ */ new Set(["tailwindcss", "tailwindcss$"]);
|
|
31
|
-
const resolveTailwindcssCss = (request, parent, isMain, options) => {
|
|
32
|
-
if (replacements.has(request)) return target;
|
|
33
|
-
if (request.startsWith("tailwindcss/")) return node_path.default.join(pkgDir, request.slice(12));
|
|
34
|
-
return original(request, parent, isMain, options);
|
|
35
|
-
};
|
|
36
|
-
moduleWithMutableResolve._resolveFilename = resolveTailwindcssCss;
|
|
37
|
-
patched.add(moduleWithMutableResolve._resolveFilename);
|
|
38
|
-
}
|
|
39
|
-
//#endregion
|
|
40
|
-
//#region src/shared/mpx.ts
|
|
41
|
-
const localRequire = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
|
|
42
|
-
const MPX_STYLE_RESOURCE_QUERY_RE$1 = /(?:^|[?&])type=styles(?:&|$)/;
|
|
43
|
-
const MPX_WEBPACK_PLUGIN_PACKAGE_RE = /@mpxjs[\\/]webpack-plugin[\\/]package\.json$/;
|
|
44
|
-
function isMpxStyleResourceQuery(query) {
|
|
45
|
-
if (typeof query !== "string") return false;
|
|
46
|
-
return MPX_STYLE_RESOURCE_QUERY_RE$1.test(query);
|
|
47
|
-
}
|
|
48
|
-
function isMpx(appType) {
|
|
49
|
-
return appType === "mpx";
|
|
50
|
-
}
|
|
51
|
-
function getTailwindcssCssEntry(pkgDir) {
|
|
52
|
-
return node_path.default.join(pkgDir, "index.css");
|
|
53
|
-
}
|
|
54
|
-
function resolveMpxWebpackPluginDir(compiler) {
|
|
55
|
-
const candidates = [
|
|
56
|
-
compiler?.context,
|
|
57
|
-
compiler?.options?.context,
|
|
58
|
-
node_process.default.cwd()
|
|
59
|
-
].filter((item) => typeof item === "string" && item.length > 0);
|
|
60
|
-
for (const candidate of candidates) try {
|
|
61
|
-
const projectRequire = (0, node_module.createRequire)(node_path.default.join(candidate, "package.json"));
|
|
62
|
-
return node_path.default.dirname(projectRequire.resolve("@mpxjs/webpack-plugin/package.json"));
|
|
63
|
-
} catch {}
|
|
64
|
-
const cachedPackageJson = Object.keys(localRequire.cache).find((file) => MPX_WEBPACK_PLUGIN_PACKAGE_RE.test(file));
|
|
65
|
-
if (cachedPackageJson) return node_path.default.dirname(cachedPackageJson);
|
|
66
|
-
try {
|
|
67
|
-
return node_path.default.dirname(localRequire.resolve("@mpxjs/webpack-plugin/package.json"));
|
|
68
|
-
} catch {
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
function isMpxWebpackPluginRequest(request) {
|
|
73
|
-
return request === "@mpxjs/webpack-plugin" || Boolean(request?.startsWith("@mpxjs/webpack-plugin/"));
|
|
74
|
-
}
|
|
75
|
-
function resolveMpxWebpackPluginRequest(request, mpxWebpackPluginDir) {
|
|
76
|
-
if (request === "@mpxjs/webpack-plugin") return mpxWebpackPluginDir;
|
|
77
|
-
return node_path.default.join(mpxWebpackPluginDir, request.slice(22));
|
|
78
|
-
}
|
|
79
|
-
function addMpxWebpackPluginAlias(alias, pkgDir) {
|
|
80
|
-
const recordLoader = node_path.default.join(pkgDir, "lib/record-loader");
|
|
81
|
-
const styleCompiler = node_path.default.join(pkgDir, "lib/style-compiler/index");
|
|
82
|
-
const stripConditionalLoader = node_path.default.join(pkgDir, "lib/style-compiler/strip-conditional-loader");
|
|
83
|
-
if (Array.isArray(alias)) alias.push({
|
|
84
|
-
name: "@mpxjs/webpack-plugin/lib/record-loader",
|
|
85
|
-
alias: recordLoader
|
|
86
|
-
}, {
|
|
87
|
-
name: "@mpxjs/webpack-plugin/lib/style-compiler/index",
|
|
88
|
-
alias: styleCompiler
|
|
89
|
-
}, {
|
|
90
|
-
name: "@mpxjs/webpack-plugin/lib/style-compiler/strip-conditional-loader",
|
|
91
|
-
alias: stripConditionalLoader
|
|
92
|
-
}, {
|
|
93
|
-
name: /^@mpxjs\/webpack-plugin\//,
|
|
94
|
-
alias: pkgDir
|
|
95
|
-
});
|
|
96
|
-
else {
|
|
97
|
-
alias["@mpxjs/webpack-plugin"] = pkgDir;
|
|
98
|
-
alias["@mpxjs/webpack-plugin$"] = pkgDir;
|
|
99
|
-
alias["@mpxjs/webpack-plugin/lib/record-loader"] = recordLoader;
|
|
100
|
-
alias["@mpxjs/webpack-plugin/lib/style-compiler/index"] = styleCompiler;
|
|
101
|
-
alias["@mpxjs/webpack-plugin/lib/style-compiler/strip-conditional-loader"] = stripConditionalLoader;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
function ensureResolveLoaderAlias(compiler, mpxWebpackPluginDir) {
|
|
105
|
-
compiler.options.resolveLoader = compiler.options.resolveLoader || {};
|
|
106
|
-
const alias = compiler.options.resolveLoader.alias ?? {};
|
|
107
|
-
compiler.options.resolveLoader.alias = alias;
|
|
108
|
-
addMpxWebpackPluginAlias(alias, mpxWebpackPluginDir);
|
|
109
|
-
}
|
|
110
|
-
function resolveMpxWebpackPluginRequire(compiler) {
|
|
111
|
-
const candidates = [
|
|
112
|
-
compiler?.context,
|
|
113
|
-
compiler?.options?.context,
|
|
114
|
-
node_process.default.cwd()
|
|
115
|
-
].filter((item) => typeof item === "string" && item.length > 0);
|
|
116
|
-
for (const candidate of candidates) try {
|
|
117
|
-
const projectRequire = (0, node_module.createRequire)(node_path.default.join(candidate, "package.json"));
|
|
118
|
-
projectRequire.resolve("@mpxjs/webpack-plugin/package.json");
|
|
119
|
-
return projectRequire;
|
|
120
|
-
} catch {}
|
|
121
|
-
const cachedPackageJson = Object.keys(localRequire.cache).find((file) => MPX_WEBPACK_PLUGIN_PACKAGE_RE.test(file));
|
|
122
|
-
if (cachedPackageJson) return (0, node_module.createRequire)(cachedPackageJson);
|
|
123
|
-
return localRequire;
|
|
124
|
-
}
|
|
125
|
-
function patchMpxWebpackPluginNormalizeLib(compiler, mpxWebpackPluginDir) {
|
|
126
|
-
if (!mpxWebpackPluginDir) return false;
|
|
127
|
-
const projectRequire = resolveMpxWebpackPluginRequire(compiler);
|
|
128
|
-
let normalize;
|
|
129
|
-
try {
|
|
130
|
-
normalize = projectRequire("@mpxjs/webpack-plugin/lib/utils/normalize");
|
|
131
|
-
} catch {
|
|
132
|
-
return false;
|
|
133
|
-
}
|
|
134
|
-
if (typeof normalize.lib !== "function") return false;
|
|
135
|
-
if (normalize.lib.__weappTwPatched) return true;
|
|
136
|
-
const wrappedLib = (file) => node_path.default.join(mpxWebpackPluginDir, "lib", file);
|
|
137
|
-
wrappedLib.__weappTwPatched = true;
|
|
138
|
-
wrappedLib.__weappTwOriginal = normalize.lib;
|
|
139
|
-
normalize.lib = wrappedLib;
|
|
140
|
-
return true;
|
|
141
|
-
}
|
|
142
|
-
function ensureMpxTailwindcssAliases(compiler, pkgDir) {
|
|
143
|
-
const tailwindcssCssEntry = getTailwindcssCssEntry(pkgDir);
|
|
144
|
-
compiler.options = compiler.options || {};
|
|
145
|
-
compiler.options.resolve = compiler.options.resolve || {};
|
|
146
|
-
const mpxWebpackPluginDir = resolveMpxWebpackPluginDir(compiler);
|
|
147
|
-
patchMpxWebpackPluginNormalizeLib(compiler, mpxWebpackPluginDir);
|
|
148
|
-
if (mpxWebpackPluginDir) ensureResolveLoaderAlias(compiler, mpxWebpackPluginDir);
|
|
149
|
-
const alias = compiler.options.resolve.alias ?? {};
|
|
150
|
-
compiler.options.resolve.alias = alias;
|
|
151
|
-
if (Array.isArray(alias)) alias.push({
|
|
152
|
-
name: "tailwindcss",
|
|
153
|
-
alias: tailwindcssCssEntry
|
|
154
|
-
}, {
|
|
155
|
-
name: "tailwindcss$",
|
|
156
|
-
alias: tailwindcssCssEntry
|
|
157
|
-
});
|
|
158
|
-
else {
|
|
159
|
-
alias.tailwindcss = tailwindcssCssEntry;
|
|
160
|
-
alias.tailwindcss$ = tailwindcssCssEntry;
|
|
161
|
-
}
|
|
162
|
-
if (mpxWebpackPluginDir) addMpxWebpackPluginAlias(alias, mpxWebpackPluginDir);
|
|
163
|
-
return tailwindcssCssEntry;
|
|
164
|
-
}
|
|
165
|
-
function patchMpxLoaderResolve(loaderContext, pkgDir, enabled) {
|
|
166
|
-
if (!enabled || typeof loaderContext.resolve !== "function") return;
|
|
167
|
-
const originalResolve = loaderContext.resolve;
|
|
168
|
-
if (originalResolve.__weappTwPatched) return;
|
|
169
|
-
const tailwindcssCssEntry = getTailwindcssCssEntry(pkgDir);
|
|
170
|
-
const mpxWebpackPluginDir = resolveMpxWebpackPluginDir(loaderContext);
|
|
171
|
-
const wrappedResolve = function(context, request, callback) {
|
|
172
|
-
if (request === "tailwindcss" || request === "tailwindcss$") return callback(null, tailwindcssCssEntry);
|
|
173
|
-
if (request?.startsWith("tailwindcss/")) return callback(null, node_path.default.join(pkgDir, request.slice(12)));
|
|
174
|
-
if (mpxWebpackPluginDir && isMpxWebpackPluginRequest(request)) return callback(null, resolveMpxWebpackPluginRequest(request, mpxWebpackPluginDir));
|
|
175
|
-
return originalResolve.call(this, context, request, callback);
|
|
176
|
-
};
|
|
177
|
-
wrappedResolve.__weappTwPatched = true;
|
|
178
|
-
loaderContext.resolve = wrappedResolve;
|
|
179
|
-
}
|
|
180
|
-
function setupMpxTailwindcssRedirect(pkgDir, enabled) {
|
|
181
|
-
if (enabled) installTailwindcssCssRedirect(pkgDir);
|
|
182
|
-
}
|
|
183
|
-
const CSS_EXT_RE = /\.css$/i;
|
|
184
|
-
function injectMpxCssRewritePreRules(compiler, loader, loaderOptions) {
|
|
185
|
-
var _compiler$options;
|
|
186
|
-
if (!loader) return;
|
|
187
|
-
const moduleOptions = (_compiler$options = compiler.options).module ?? (_compiler$options.module = { rules: [] });
|
|
188
|
-
moduleOptions.rules = moduleOptions.rules || [];
|
|
189
|
-
const createRule = (match) => ({
|
|
190
|
-
...match,
|
|
191
|
-
enforce: "pre",
|
|
192
|
-
use: [{
|
|
193
|
-
loader,
|
|
194
|
-
options: loaderOptions
|
|
195
|
-
}]
|
|
196
|
-
});
|
|
197
|
-
moduleOptions.rules.unshift(createRule({ resourceQuery: (query) => isMpxStyleResourceQuery(query) }), createRule({
|
|
198
|
-
test: CSS_EXT_RE,
|
|
199
|
-
resourceQuery: (query) => !isMpxStyleResourceQuery(query)
|
|
200
|
-
}));
|
|
201
|
-
}
|
|
202
|
-
//#endregion
|
|
203
23
|
//#region src/bundlers/webpack/BaseUnifiedPlugin/shared.ts
|
|
204
|
-
const MPX_STYLE_RESOURCE_QUERY_RE = /(?:\?|&)type=styles\b/;
|
|
205
24
|
function getCacheKey(filename) {
|
|
206
25
|
return filename;
|
|
207
26
|
}
|
|
@@ -209,12 +28,11 @@ function stripResourceQuery(resource) {
|
|
|
209
28
|
if (typeof resource !== "string") return resource;
|
|
210
29
|
return require_source_candidate_scan_signature.stripRequestQuery(resource);
|
|
211
30
|
}
|
|
212
|
-
function isCssLikeModuleResource(resource, cssMatcher
|
|
31
|
+
function isCssLikeModuleResource(resource, cssMatcher) {
|
|
213
32
|
if (typeof resource !== "string") return false;
|
|
214
33
|
const normalizedResource = stripResourceQuery(resource);
|
|
215
34
|
if (normalizedResource && cssMatcher(normalizedResource)) return true;
|
|
216
35
|
if (require_source_candidate_scan_signature.isSourceStyleRequest(resource)) return true;
|
|
217
|
-
if (appType === "mpx") return MPX_STYLE_RESOURCE_QUERY_RE.test(resource);
|
|
218
36
|
return false;
|
|
219
37
|
}
|
|
220
38
|
function hasLoaderEntry(entries, target) {
|
|
@@ -358,6 +176,11 @@ function hasMissingRuntimeCandidates(classSet, candidates) {
|
|
|
358
176
|
for (const candidate of candidates) if (isRuntimeTransformCandidate(candidate) && !classSet.has(candidate)) return true;
|
|
359
177
|
return false;
|
|
360
178
|
}
|
|
179
|
+
function hasStaleRuntimeCandidates(classSet, candidates) {
|
|
180
|
+
if (!classSet || !candidates) return false;
|
|
181
|
+
for (const candidate of classSet) if (isRuntimeTransformCandidate(candidate) && !candidates.has(candidate)) return true;
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
361
184
|
function resolveGeneratedCssRuntimeCandidates(source, fallbackClassSet) {
|
|
362
185
|
const classSet = collectGeneratedCssRuntimeCandidates(source);
|
|
363
186
|
if (classSet.size > 0 || fallbackClassSet === void 0) return classSet;
|
|
@@ -398,7 +221,7 @@ function resolveWebpackGeneratorRawSource(rawSource, cssHandlerOptions) {
|
|
|
398
221
|
}
|
|
399
222
|
function shouldConsumeWebpackLoaderGeneratedCss(options) {
|
|
400
223
|
if (!options.shouldRegenerateExplicitTailwindV4CssSource) return true;
|
|
401
|
-
if (options.watchMode === true && options.loaderGeneratedClassSet && options.sourceCandidates && hasMissingRuntimeCandidates(options.loaderGeneratedClassSet, options.sourceCandidates)) return false;
|
|
224
|
+
if (options.watchMode === true && options.loaderGeneratedClassSet && options.sourceCandidates && (hasMissingRuntimeCandidates(options.loaderGeneratedClassSet, options.sourceCandidates) || hasStaleRuntimeCandidates(options.loaderGeneratedClassSet, options.sourceCandidates))) return false;
|
|
402
225
|
return options.hasBundlerGeneratedCssMarker;
|
|
403
226
|
}
|
|
404
227
|
function hasUsableWebpackGeneratorCssSources(cssSources) {
|
|
@@ -2236,6 +2059,183 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
2236
2059
|
});
|
|
2237
2060
|
}
|
|
2238
2061
|
//#endregion
|
|
2062
|
+
//#region src/shared/tailwindcss-css-redirect.ts
|
|
2063
|
+
const moduleWithMutableResolve = node_module.default;
|
|
2064
|
+
const patched = /* @__PURE__ */ new WeakSet();
|
|
2065
|
+
function installTailwindcssCssRedirect(pkgDir) {
|
|
2066
|
+
const target = node_path.default.join(pkgDir, "index.css");
|
|
2067
|
+
const original = moduleWithMutableResolve._resolveFilename;
|
|
2068
|
+
if (patched.has(original)) return;
|
|
2069
|
+
const replacements = /* @__PURE__ */ new Set(["tailwindcss", "tailwindcss$"]);
|
|
2070
|
+
const resolveTailwindcssCss = (request, parent, isMain, options) => {
|
|
2071
|
+
if (replacements.has(request)) return target;
|
|
2072
|
+
if (request.startsWith("tailwindcss/")) return node_path.default.join(pkgDir, request.slice(12));
|
|
2073
|
+
return original(request, parent, isMain, options);
|
|
2074
|
+
};
|
|
2075
|
+
moduleWithMutableResolve._resolveFilename = resolveTailwindcssCss;
|
|
2076
|
+
patched.add(moduleWithMutableResolve._resolveFilename);
|
|
2077
|
+
}
|
|
2078
|
+
//#endregion
|
|
2079
|
+
//#region src/shared/mpx.ts
|
|
2080
|
+
const localRequire = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
|
|
2081
|
+
const MPX_STYLE_RESOURCE_QUERY_RE = /(?:^|[?&])type=styles(?:&|$)/;
|
|
2082
|
+
const MPX_WEBPACK_PLUGIN_PACKAGE_RE = /@mpxjs[\\/]webpack-plugin[\\/]package\.json$/;
|
|
2083
|
+
function isMpxStyleResourceQuery(query) {
|
|
2084
|
+
if (typeof query !== "string") return false;
|
|
2085
|
+
return MPX_STYLE_RESOURCE_QUERY_RE.test(query);
|
|
2086
|
+
}
|
|
2087
|
+
function getTailwindcssCssEntry(pkgDir) {
|
|
2088
|
+
return node_path.default.join(pkgDir, "index.css");
|
|
2089
|
+
}
|
|
2090
|
+
function resolveMpxWebpackPluginDir(compiler) {
|
|
2091
|
+
const candidates = [
|
|
2092
|
+
compiler?.context,
|
|
2093
|
+
compiler?.options?.context,
|
|
2094
|
+
node_process.default.cwd()
|
|
2095
|
+
].filter((item) => typeof item === "string" && item.length > 0);
|
|
2096
|
+
for (const candidate of candidates) try {
|
|
2097
|
+
const projectRequire = (0, node_module.createRequire)(node_path.default.join(candidate, "package.json"));
|
|
2098
|
+
return node_path.default.dirname(projectRequire.resolve("@mpxjs/webpack-plugin/package.json"));
|
|
2099
|
+
} catch {}
|
|
2100
|
+
const cachedPackageJson = Object.keys(localRequire.cache).find((file) => MPX_WEBPACK_PLUGIN_PACKAGE_RE.test(file));
|
|
2101
|
+
if (cachedPackageJson) return node_path.default.dirname(cachedPackageJson);
|
|
2102
|
+
try {
|
|
2103
|
+
return node_path.default.dirname(localRequire.resolve("@mpxjs/webpack-plugin/package.json"));
|
|
2104
|
+
} catch {
|
|
2105
|
+
return;
|
|
2106
|
+
}
|
|
2107
|
+
}
|
|
2108
|
+
function isMpxWebpackPluginRequest(request) {
|
|
2109
|
+
return request === "@mpxjs/webpack-plugin" || Boolean(request?.startsWith("@mpxjs/webpack-plugin/"));
|
|
2110
|
+
}
|
|
2111
|
+
function resolveMpxWebpackPluginRequest(request, mpxWebpackPluginDir) {
|
|
2112
|
+
if (request === "@mpxjs/webpack-plugin") return mpxWebpackPluginDir;
|
|
2113
|
+
return node_path.default.join(mpxWebpackPluginDir, request.slice(22));
|
|
2114
|
+
}
|
|
2115
|
+
function addMpxWebpackPluginAlias(alias, pkgDir) {
|
|
2116
|
+
const recordLoader = node_path.default.join(pkgDir, "lib/record-loader");
|
|
2117
|
+
const styleCompiler = node_path.default.join(pkgDir, "lib/style-compiler/index");
|
|
2118
|
+
const stripConditionalLoader = node_path.default.join(pkgDir, "lib/style-compiler/strip-conditional-loader");
|
|
2119
|
+
if (Array.isArray(alias)) alias.push({
|
|
2120
|
+
name: "@mpxjs/webpack-plugin/lib/record-loader",
|
|
2121
|
+
alias: recordLoader
|
|
2122
|
+
}, {
|
|
2123
|
+
name: "@mpxjs/webpack-plugin/lib/style-compiler/index",
|
|
2124
|
+
alias: styleCompiler
|
|
2125
|
+
}, {
|
|
2126
|
+
name: "@mpxjs/webpack-plugin/lib/style-compiler/strip-conditional-loader",
|
|
2127
|
+
alias: stripConditionalLoader
|
|
2128
|
+
}, {
|
|
2129
|
+
name: /^@mpxjs\/webpack-plugin\//,
|
|
2130
|
+
alias: pkgDir
|
|
2131
|
+
});
|
|
2132
|
+
else {
|
|
2133
|
+
alias["@mpxjs/webpack-plugin"] = pkgDir;
|
|
2134
|
+
alias["@mpxjs/webpack-plugin$"] = pkgDir;
|
|
2135
|
+
alias["@mpxjs/webpack-plugin/lib/record-loader"] = recordLoader;
|
|
2136
|
+
alias["@mpxjs/webpack-plugin/lib/style-compiler/index"] = styleCompiler;
|
|
2137
|
+
alias["@mpxjs/webpack-plugin/lib/style-compiler/strip-conditional-loader"] = stripConditionalLoader;
|
|
2138
|
+
}
|
|
2139
|
+
}
|
|
2140
|
+
function ensureResolveLoaderAlias(compiler, mpxWebpackPluginDir) {
|
|
2141
|
+
compiler.options.resolveLoader = compiler.options.resolveLoader || {};
|
|
2142
|
+
const alias = compiler.options.resolveLoader.alias ?? {};
|
|
2143
|
+
compiler.options.resolveLoader.alias = alias;
|
|
2144
|
+
addMpxWebpackPluginAlias(alias, mpxWebpackPluginDir);
|
|
2145
|
+
}
|
|
2146
|
+
function resolveMpxWebpackPluginRequire(compiler) {
|
|
2147
|
+
const candidates = [
|
|
2148
|
+
compiler?.context,
|
|
2149
|
+
compiler?.options?.context,
|
|
2150
|
+
node_process.default.cwd()
|
|
2151
|
+
].filter((item) => typeof item === "string" && item.length > 0);
|
|
2152
|
+
for (const candidate of candidates) try {
|
|
2153
|
+
const projectRequire = (0, node_module.createRequire)(node_path.default.join(candidate, "package.json"));
|
|
2154
|
+
projectRequire.resolve("@mpxjs/webpack-plugin/package.json");
|
|
2155
|
+
return projectRequire;
|
|
2156
|
+
} catch {}
|
|
2157
|
+
const cachedPackageJson = Object.keys(localRequire.cache).find((file) => MPX_WEBPACK_PLUGIN_PACKAGE_RE.test(file));
|
|
2158
|
+
if (cachedPackageJson) return (0, node_module.createRequire)(cachedPackageJson);
|
|
2159
|
+
return localRequire;
|
|
2160
|
+
}
|
|
2161
|
+
function patchMpxWebpackPluginNormalizeLib(compiler, mpxWebpackPluginDir) {
|
|
2162
|
+
if (!mpxWebpackPluginDir) return false;
|
|
2163
|
+
const projectRequire = resolveMpxWebpackPluginRequire(compiler);
|
|
2164
|
+
let normalize;
|
|
2165
|
+
try {
|
|
2166
|
+
normalize = projectRequire("@mpxjs/webpack-plugin/lib/utils/normalize");
|
|
2167
|
+
} catch {
|
|
2168
|
+
return false;
|
|
2169
|
+
}
|
|
2170
|
+
if (typeof normalize.lib !== "function") return false;
|
|
2171
|
+
if (normalize.lib.__weappTwPatched) return true;
|
|
2172
|
+
const wrappedLib = (file) => node_path.default.join(mpxWebpackPluginDir, "lib", file);
|
|
2173
|
+
wrappedLib.__weappTwPatched = true;
|
|
2174
|
+
wrappedLib.__weappTwOriginal = normalize.lib;
|
|
2175
|
+
normalize.lib = wrappedLib;
|
|
2176
|
+
return true;
|
|
2177
|
+
}
|
|
2178
|
+
function ensureMpxTailwindcssAliases(compiler, pkgDir) {
|
|
2179
|
+
const tailwindcssCssEntry = getTailwindcssCssEntry(pkgDir);
|
|
2180
|
+
compiler.options = compiler.options || {};
|
|
2181
|
+
compiler.options.resolve = compiler.options.resolve || {};
|
|
2182
|
+
const mpxWebpackPluginDir = resolveMpxWebpackPluginDir(compiler);
|
|
2183
|
+
patchMpxWebpackPluginNormalizeLib(compiler, mpxWebpackPluginDir);
|
|
2184
|
+
if (mpxWebpackPluginDir) ensureResolveLoaderAlias(compiler, mpxWebpackPluginDir);
|
|
2185
|
+
const alias = compiler.options.resolve.alias ?? {};
|
|
2186
|
+
compiler.options.resolve.alias = alias;
|
|
2187
|
+
if (Array.isArray(alias)) alias.push({
|
|
2188
|
+
name: "tailwindcss",
|
|
2189
|
+
alias: tailwindcssCssEntry
|
|
2190
|
+
}, {
|
|
2191
|
+
name: "tailwindcss$",
|
|
2192
|
+
alias: tailwindcssCssEntry
|
|
2193
|
+
});
|
|
2194
|
+
else {
|
|
2195
|
+
alias.tailwindcss = tailwindcssCssEntry;
|
|
2196
|
+
alias.tailwindcss$ = tailwindcssCssEntry;
|
|
2197
|
+
}
|
|
2198
|
+
if (mpxWebpackPluginDir) addMpxWebpackPluginAlias(alias, mpxWebpackPluginDir);
|
|
2199
|
+
return tailwindcssCssEntry;
|
|
2200
|
+
}
|
|
2201
|
+
function patchMpxLoaderResolve(loaderContext, pkgDir, enabled) {
|
|
2202
|
+
if (!enabled || typeof loaderContext.resolve !== "function") return;
|
|
2203
|
+
const originalResolve = loaderContext.resolve;
|
|
2204
|
+
if (originalResolve.__weappTwPatched) return;
|
|
2205
|
+
const tailwindcssCssEntry = getTailwindcssCssEntry(pkgDir);
|
|
2206
|
+
const mpxWebpackPluginDir = resolveMpxWebpackPluginDir(loaderContext);
|
|
2207
|
+
const wrappedResolve = function(context, request, callback) {
|
|
2208
|
+
if (request === "tailwindcss" || request === "tailwindcss$") return callback(null, tailwindcssCssEntry);
|
|
2209
|
+
if (request?.startsWith("tailwindcss/")) return callback(null, node_path.default.join(pkgDir, request.slice(12)));
|
|
2210
|
+
if (mpxWebpackPluginDir && isMpxWebpackPluginRequest(request)) return callback(null, resolveMpxWebpackPluginRequest(request, mpxWebpackPluginDir));
|
|
2211
|
+
return originalResolve.call(this, context, request, callback);
|
|
2212
|
+
};
|
|
2213
|
+
wrappedResolve.__weappTwPatched = true;
|
|
2214
|
+
loaderContext.resolve = wrappedResolve;
|
|
2215
|
+
}
|
|
2216
|
+
function setupMpxTailwindcssRedirect(pkgDir, enabled) {
|
|
2217
|
+
if (enabled) installTailwindcssCssRedirect(pkgDir);
|
|
2218
|
+
}
|
|
2219
|
+
const CSS_EXT_RE = /\.css$/i;
|
|
2220
|
+
function injectMpxCssRewritePreRules(compiler, loader, loaderOptions) {
|
|
2221
|
+
var _compiler$options;
|
|
2222
|
+
if (!loader) return;
|
|
2223
|
+
const moduleOptions = (_compiler$options = compiler.options).module ?? (_compiler$options.module = { rules: [] });
|
|
2224
|
+
moduleOptions.rules = moduleOptions.rules || [];
|
|
2225
|
+
const createRule = (match) => ({
|
|
2226
|
+
...match,
|
|
2227
|
+
enforce: "pre",
|
|
2228
|
+
use: [{
|
|
2229
|
+
loader,
|
|
2230
|
+
options: loaderOptions
|
|
2231
|
+
}]
|
|
2232
|
+
});
|
|
2233
|
+
moduleOptions.rules.unshift(createRule({ resourceQuery: (query) => isMpxStyleResourceQuery(query) }), createRule({
|
|
2234
|
+
test: CSS_EXT_RE,
|
|
2235
|
+
resourceQuery: (query) => !isMpxStyleResourceQuery(query)
|
|
2236
|
+
}));
|
|
2237
|
+
}
|
|
2238
|
+
//#endregion
|
|
2239
2239
|
//#region src/bundlers/webpack/loaders/runtime-registry.ts
|
|
2240
2240
|
const runtimeRegistryHolder = globalThis;
|
|
2241
2241
|
const runtimeRegistry = runtimeRegistryHolder.__WEAPP_TW_WEBPACK_LOADER_RUNTIME_REGISTRY__ ?? (runtimeRegistryHolder.__WEAPP_TW_WEBPACK_LOADER_RUNTIME_REGISTRY__ = /* @__PURE__ */ new Map());
|
|
@@ -2262,11 +2262,13 @@ function createPrioritizedFinder(targets) {
|
|
|
2262
2262
|
return -1;
|
|
2263
2263
|
};
|
|
2264
2264
|
}
|
|
2265
|
-
function
|
|
2266
|
-
|
|
2265
|
+
function createMpxLoaderAnchorFinders() {
|
|
2266
|
+
return {
|
|
2267
2267
|
findRewriteAnchor: createPrioritizedFinder(MPX_REWRITE_PRECEDENCE_LOADERS),
|
|
2268
2268
|
findClassSetAnchor: createFinder([MPX_STYLE_COMPILER_LOADER])
|
|
2269
2269
|
};
|
|
2270
|
+
}
|
|
2271
|
+
function createDefaultLoaderAnchorFinders() {
|
|
2270
2272
|
const fallbackFinder = createFinder(["postcss-loader"]);
|
|
2271
2273
|
return {
|
|
2272
2274
|
findRewriteAnchor: fallbackFinder,
|
|
@@ -2276,8 +2278,7 @@ function createLoaderAnchorFinders(appType) {
|
|
|
2276
2278
|
//#endregion
|
|
2277
2279
|
//#region src/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.ts
|
|
2278
2280
|
function setupWebpackV5Loaders(options) {
|
|
2279
|
-
const { compiler, options: compilerOptions, appType, weappTailwindcssPackageDir, shouldRewriteCssImports, runtimeLoaderPath, registerAutoCssSource, runtimeState, getClassSetInLoader, getRuntimeSetInLoader, markWebpackProcessedCssSource, markWebpackCssSourceModule, registerWebpackGeneratedCss, registerWebpackCssSourceFile, getRuntimeWatchDependencies, runtimeRegistryKey = `weapp-tailwindcss-${Date.now()}-${Math.random().toString(36).slice(2)}`, debug } = options;
|
|
2280
|
-
const isMpxApp = isMpx(appType);
|
|
2281
|
+
const { compiler, options: compilerOptions, appType, weappTailwindcssPackageDir, shouldRewriteCssImports, runtimeLoaderPath, registerAutoCssSource, runtimeState, getClassSetInLoader, getRuntimeSetInLoader, markWebpackProcessedCssSource, markWebpackCssSourceModule, registerWebpackGeneratedCss, registerWebpackCssSourceFile, getRuntimeWatchDependencies, loaderAnchorFinders = createDefaultLoaderAnchorFinders(), mpxCssImportRewrite = false, runtimeRegistryKey = `weapp-tailwindcss-${Date.now()}-${Math.random().toString(36).slice(2)}`, debug } = options;
|
|
2281
2282
|
const generatorTarget = compilerOptions.generator?.target ?? require_v4_engine.inferGeneratorTargetFromEnv();
|
|
2282
2283
|
const generatorBranch = require_generator.resolveRuntimeBranch({
|
|
2283
2284
|
appType: compilerOptions.appType,
|
|
@@ -2286,7 +2287,7 @@ function setupWebpackV5Loaders(options) {
|
|
|
2286
2287
|
tailwindcssMajorVersion: runtimeState.tailwindRuntime.majorVersion,
|
|
2287
2288
|
uniAppX: compilerOptions.uniAppX
|
|
2288
2289
|
});
|
|
2289
|
-
if (shouldRewriteCssImports &&
|
|
2290
|
+
if (shouldRewriteCssImports && mpxCssImportRewrite) ensureMpxTailwindcssAliases(compiler, weappTailwindcssPackageDir);
|
|
2290
2291
|
const runtimeClassSetLoader = runtimeLoaderPath ?? node_path.default.resolve(__dirname, "./weapp-tw-runtime-classset-loader.js");
|
|
2291
2292
|
const shouldInjectRuntimeClassSetLoader = !generatorBranch.isWeb;
|
|
2292
2293
|
const shouldInjectCssImportRewriteLoader = shouldRewriteCssImports || !generatorBranch.isWeb || runtimeState.tailwindRuntime.majorVersion === 4;
|
|
@@ -2317,9 +2318,9 @@ function setupWebpackV5Loaders(options) {
|
|
|
2317
2318
|
};
|
|
2318
2319
|
compiler.hooks.watchClose?.tap?.(require_context.pluginName, cleanupWebpackLoaderRuntime);
|
|
2319
2320
|
compiler.hooks.shutdown?.tap?.(require_context.pluginName, cleanupWebpackLoaderRuntime);
|
|
2320
|
-
const { findRewriteAnchor, findClassSetAnchor } =
|
|
2321
|
+
const { findRewriteAnchor, findClassSetAnchor } = loaderAnchorFinders;
|
|
2321
2322
|
const cssImportRewriteLoaderOptions = runtimeLoaderRewriteOptions ? { tailwindcssImportRewriteRuntimeKey: runtimeRegistryKey } : void 0;
|
|
2322
|
-
if (runtimeCssImportRewriteLoader && shouldRewriteCssImports && cssImportRewriteLoaderOptions &&
|
|
2323
|
+
if (runtimeCssImportRewriteLoader && shouldRewriteCssImports && cssImportRewriteLoaderOptions && mpxCssImportRewrite) injectMpxCssRewritePreRules(compiler, runtimeCssImportRewriteLoader, cssImportRewriteLoaderOptions);
|
|
2323
2324
|
const createRuntimeClassSetLoaderEntry = () => ({
|
|
2324
2325
|
loader: runtimeClassSetLoader,
|
|
2325
2326
|
options: { weappTailwindcssRuntimeKey: runtimeRegistryKey },
|
|
@@ -2339,7 +2340,7 @@ function setupWebpackV5Loaders(options) {
|
|
|
2339
2340
|
compiler.hooks.compilation.tap(require_context.pluginName, (compilation) => {
|
|
2340
2341
|
NormalModule.getCompilationHooks(compilation).loader.tap(require_context.pluginName, (_loaderContext, module) => {
|
|
2341
2342
|
if (!(runtimeClassSetLoaderExists || runtimeCssImportRewriteLoaderExists)) return;
|
|
2342
|
-
patchMpxLoaderResolve(_loaderContext, weappTailwindcssPackageDir, shouldRewriteCssImports &&
|
|
2343
|
+
patchMpxLoaderResolve(_loaderContext, weappTailwindcssPackageDir, shouldRewriteCssImports && mpxCssImportRewrite);
|
|
2343
2344
|
const loaderEntries = module.loaders || [];
|
|
2344
2345
|
let rewriteAnchorIdx = findRewriteAnchor(loaderEntries);
|
|
2345
2346
|
const classSetAnchorIdx = findClassSetAnchor(loaderEntries);
|
|
@@ -2385,16 +2386,12 @@ function setupWebpackV5Loaders(options) {
|
|
|
2385
2386
|
});
|
|
2386
2387
|
}
|
|
2387
2388
|
//#endregion
|
|
2388
|
-
//#region src/bundlers/webpack/
|
|
2389
|
+
//#region src/bundlers/webpack/shared/create-framework-plugin.ts
|
|
2389
2390
|
const debug = require_context.createDebug();
|
|
2390
2391
|
const weappTailwindcssPackageDir = require_source_candidate_scan_signature.resolvePackageDir("weapp-tailwindcss");
|
|
2391
2392
|
const outputIgnoredPredicatePath = Symbol("weapp-tailwindcss.outputIgnoredPredicatePath");
|
|
2392
2393
|
function shouldKeepPreviousWebpackCssSource(previous, next) {
|
|
2393
|
-
|
|
2394
|
-
if (previous.processed === true || next.processed === true || !previous.css || !next.css || previous.css === next.css) return false;
|
|
2395
|
-
const previousMarkers = collectWebpackAssetUserCssMarkers(previous.css);
|
|
2396
|
-
const nextMarkers = collectWebpackAssetUserCssMarkers(next.css);
|
|
2397
|
-
return previousMarkers.size > nextMarkers.size && [...nextMarkers].every((marker) => previousMarkers.has(marker));
|
|
2394
|
+
return next.processed === true && previous.processed === false;
|
|
2398
2395
|
}
|
|
2399
2396
|
function normalizeIgnoredList(ignored) {
|
|
2400
2397
|
return (Array.isArray(ignored) ? [...ignored] : [ignored]).filter((item) => typeof item === "string" || item instanceof RegExp || typeof item === "function");
|
|
@@ -2455,32 +2452,40 @@ function setupWebpackWatchOutputIgnore(compiler) {
|
|
|
2455
2452
|
}
|
|
2456
2453
|
});
|
|
2457
2454
|
}
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
var WeappTailwindcss = class {
|
|
2464
|
-
constructor(options = {}) {
|
|
2455
|
+
function isInternalUserDefinedOptions(options) {
|
|
2456
|
+
return typeof options.onLoad === "function" && typeof options.mainCssChunkMatcher === "function" && typeof options.tailwindRuntime === "object" && typeof options.refreshTailwindcssRuntime === "function";
|
|
2457
|
+
}
|
|
2458
|
+
var WebpackFrameworkPlugin = class {
|
|
2459
|
+
constructor(options = {}, frameworkBranch) {
|
|
2465
2460
|
require_context._defineProperty(this, "options", void 0);
|
|
2466
2461
|
require_context._defineProperty(this, "appType", void 0);
|
|
2467
2462
|
require_context._defineProperty(this, "hasInitialTailwindCssRoots", void 0);
|
|
2463
|
+
require_context._defineProperty(this, "frameworkBranch", void 0);
|
|
2464
|
+
this.frameworkBranch = frameworkBranch;
|
|
2468
2465
|
this.hasInitialTailwindCssRoots = require_v4_engine.hasConfiguredTailwindV4CssRoots(options);
|
|
2469
|
-
this.options = require_context.getCompilerContext({
|
|
2466
|
+
this.options = isInternalUserDefinedOptions(options) ? options : require_context.getCompilerContext({
|
|
2470
2467
|
...options,
|
|
2471
2468
|
__internalDeferMissingCssEntriesWarning: true
|
|
2472
2469
|
});
|
|
2473
2470
|
this.appType = this.options.appType;
|
|
2474
2471
|
}
|
|
2475
2472
|
apply(compiler) {
|
|
2473
|
+
debug("apply webpack framework plugin framework=%s", this.frameworkBranch.frameworkName);
|
|
2476
2474
|
compiler.options = compiler.options || {};
|
|
2477
2475
|
const { disabled, onLoad, runtimeLoaderPath, tailwindRuntime, refreshTailwindcssRuntime, styleInjector } = this.options;
|
|
2478
2476
|
const initialTailwindRuntime = tailwindRuntime;
|
|
2479
2477
|
const refreshTailwindRuntime = refreshTailwindcssRuntime;
|
|
2480
2478
|
const disabledOptions = require_source_candidate_scan_signature.resolvePluginDisabledState(disabled);
|
|
2481
2479
|
const shouldRewriteCssImports = this.options.rewriteCssImports === true;
|
|
2482
|
-
const
|
|
2483
|
-
|
|
2480
|
+
const frameworkProfile = require_source_candidate_scan_signature.resolveWebpackFrameworkProfile({
|
|
2481
|
+
appType: this.appType,
|
|
2482
|
+
detectEnv: true,
|
|
2483
|
+
env: node_process.default.env,
|
|
2484
|
+
root: compiler.options.context ?? compiler.context,
|
|
2485
|
+
uniAppX: this.options.uniAppX
|
|
2486
|
+
});
|
|
2487
|
+
this.appType = frameworkProfile.appType ?? this.appType;
|
|
2488
|
+
if (shouldRewriteCssImports) this.frameworkBranch.setupCssImportRewriteRedirect?.(weappTailwindcssPackageDir);
|
|
2484
2489
|
if (disabledOptions.plugin) return;
|
|
2485
2490
|
if (initialTailwindRuntime.majorVersion !== 4) throw new Error("weapp-tailwindcss/webpack 新生成管线仅支持 Tailwind CSS v4,请升级 tailwindcss 或停留在旧版 weapp-tailwindcss。");
|
|
2486
2491
|
setupWebpackWatchOutputIgnore(compiler);
|
|
@@ -2675,6 +2680,8 @@ var WeappTailwindcss = class {
|
|
|
2675
2680
|
contexts: runtimeWatchDependencyContexts
|
|
2676
2681
|
};
|
|
2677
2682
|
},
|
|
2683
|
+
loaderAnchorFinders: this.frameworkBranch.loaderAnchorFinders,
|
|
2684
|
+
mpxCssImportRewrite: this.frameworkBranch.mpxCssImportRewrite,
|
|
2678
2685
|
debug
|
|
2679
2686
|
});
|
|
2680
2687
|
setupWebpackV5ProcessAssetsHook({
|
|
@@ -2702,7 +2709,105 @@ var WeappTailwindcss = class {
|
|
|
2702
2709
|
prepareWebpackCssSources,
|
|
2703
2710
|
debug
|
|
2704
2711
|
});
|
|
2705
|
-
require_source_candidate_scan_signature.createBuiltinWebpackStyleInjectorPlugin(styleInjector, this.
|
|
2712
|
+
require_source_candidate_scan_signature.createBuiltinWebpackStyleInjectorPlugin(styleInjector, this.frameworkBranch.styleInjectorDelegate)?.apply(compiler);
|
|
2713
|
+
}
|
|
2714
|
+
};
|
|
2715
|
+
//#endregion
|
|
2716
|
+
//#region src/bundlers/webpack/frameworks/generic/index.ts
|
|
2717
|
+
var GenericWebpackPlugin = class extends WebpackFrameworkPlugin {
|
|
2718
|
+
constructor(options = {}) {
|
|
2719
|
+
super(options, {
|
|
2720
|
+
frameworkName: "generic",
|
|
2721
|
+
loaderAnchorFinders: createDefaultLoaderAnchorFinders(),
|
|
2722
|
+
styleInjectorDelegate: require_source_candidate_scan_signature.webpackStyleInjectorDelegates.generic
|
|
2723
|
+
});
|
|
2724
|
+
}
|
|
2725
|
+
};
|
|
2726
|
+
//#endregion
|
|
2727
|
+
//#region src/bundlers/webpack/frameworks/mpx/index.ts
|
|
2728
|
+
var MpxWebpackPlugin = class extends WebpackFrameworkPlugin {
|
|
2729
|
+
constructor(options = {}) {
|
|
2730
|
+
super(options, {
|
|
2731
|
+
frameworkName: "mpx",
|
|
2732
|
+
loaderAnchorFinders: createMpxLoaderAnchorFinders(),
|
|
2733
|
+
mpxCssImportRewrite: true,
|
|
2734
|
+
setupCssImportRewriteRedirect: (packageDir) => setupMpxTailwindcssRedirect(packageDir, true),
|
|
2735
|
+
styleInjectorDelegate: require_source_candidate_scan_signature.webpackStyleInjectorDelegates.mpx
|
|
2736
|
+
});
|
|
2737
|
+
}
|
|
2738
|
+
};
|
|
2739
|
+
//#endregion
|
|
2740
|
+
//#region src/bundlers/webpack/frameworks/taro/index.ts
|
|
2741
|
+
var TaroWebpackPlugin = class extends WebpackFrameworkPlugin {
|
|
2742
|
+
constructor(options = {}) {
|
|
2743
|
+
super(options, {
|
|
2744
|
+
frameworkName: "taro",
|
|
2745
|
+
loaderAnchorFinders: createDefaultLoaderAnchorFinders(),
|
|
2746
|
+
styleInjectorDelegate: require_source_candidate_scan_signature.webpackStyleInjectorDelegates.taro
|
|
2747
|
+
});
|
|
2748
|
+
}
|
|
2749
|
+
};
|
|
2750
|
+
//#endregion
|
|
2751
|
+
//#region src/bundlers/webpack/frameworks/uni-app/index.ts
|
|
2752
|
+
var UniAppWebpackPlugin = class extends WebpackFrameworkPlugin {
|
|
2753
|
+
constructor(options = {}) {
|
|
2754
|
+
super(options, {
|
|
2755
|
+
frameworkName: "uni-app",
|
|
2756
|
+
loaderAnchorFinders: createDefaultLoaderAnchorFinders(),
|
|
2757
|
+
styleInjectorDelegate: require_source_candidate_scan_signature.webpackStyleInjectorDelegates.uniApp
|
|
2758
|
+
});
|
|
2759
|
+
}
|
|
2760
|
+
};
|
|
2761
|
+
//#endregion
|
|
2762
|
+
//#region src/bundlers/webpack/frameworks/weapp-vite/index.ts
|
|
2763
|
+
var WeappViteWebpackPlugin = class extends WebpackFrameworkPlugin {
|
|
2764
|
+
constructor(options = {}) {
|
|
2765
|
+
super(options, {
|
|
2766
|
+
frameworkName: "weapp-vite",
|
|
2767
|
+
loaderAnchorFinders: createDefaultLoaderAnchorFinders(),
|
|
2768
|
+
styleInjectorDelegate: require_source_candidate_scan_signature.webpackStyleInjectorDelegates.generic
|
|
2769
|
+
});
|
|
2770
|
+
}
|
|
2771
|
+
};
|
|
2772
|
+
//#endregion
|
|
2773
|
+
//#region src/bundlers/webpack/frameworks/index.ts
|
|
2774
|
+
function createWebpackFrameworkPlugin(frameworkName, options = {}) {
|
|
2775
|
+
switch (frameworkName) {
|
|
2776
|
+
case "mpx": return new MpxWebpackPlugin(options);
|
|
2777
|
+
case "taro": return new TaroWebpackPlugin(options);
|
|
2778
|
+
case "uni-app": return new UniAppWebpackPlugin(options);
|
|
2779
|
+
case "generic": return new GenericWebpackPlugin(options);
|
|
2780
|
+
default: return new WeappViteWebpackPlugin(options);
|
|
2781
|
+
}
|
|
2782
|
+
}
|
|
2783
|
+
//#endregion
|
|
2784
|
+
//#region src/bundlers/webpack/BaseUnifiedPlugin/v5.ts
|
|
2785
|
+
/**
|
|
2786
|
+
* @name WeappTailwindcss
|
|
2787
|
+
* @description Webpack 入口只负责早期识别框架分支,具体 hook 由 framework 目录下的插件拥有。
|
|
2788
|
+
* @link https://tw.icebreaker.top/docs/intro
|
|
2789
|
+
*/
|
|
2790
|
+
var WeappTailwindcss = class {
|
|
2791
|
+
constructor(options = {}) {
|
|
2792
|
+
require_context._defineProperty(this, "options", void 0);
|
|
2793
|
+
require_context._defineProperty(this, "appType", void 0);
|
|
2794
|
+
this.options = require_context.getCompilerContext({
|
|
2795
|
+
...options,
|
|
2796
|
+
__internalDeferMissingCssEntriesWarning: true
|
|
2797
|
+
});
|
|
2798
|
+
this.appType = this.options.appType;
|
|
2799
|
+
}
|
|
2800
|
+
apply(compiler) {
|
|
2801
|
+
const plugin = createWebpackFrameworkPlugin(require_source_candidate_scan_signature.resolveWebpackFrameworkProfile({
|
|
2802
|
+
appType: this.appType,
|
|
2803
|
+
detectEnv: true,
|
|
2804
|
+
env: node_process.default.env,
|
|
2805
|
+
root: compiler.options?.context ?? compiler.context,
|
|
2806
|
+
uniAppX: this.options.uniAppX
|
|
2807
|
+
}).frameworkName, this.options);
|
|
2808
|
+
plugin.apply(compiler);
|
|
2809
|
+
this.options = plugin.options;
|
|
2810
|
+
this.appType = plugin.appType;
|
|
2706
2811
|
}
|
|
2707
2812
|
};
|
|
2708
2813
|
//#endregion
|
package/dist/webpack.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_webpack = require("./webpack-
|
|
2
|
+
const require_webpack = require("./webpack-BhM4Hqla.js");
|
|
3
3
|
exports.WeappTailwindcss = require_webpack.WeappTailwindcss;
|
|
4
4
|
exports.weappTailwindcss = require_webpack.WeappTailwindcss;
|
|
5
5
|
exports.weappTailwindcssPackageDir = require_webpack.weappTailwindcssPackageDir;
|
package/dist/webpack.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as weappTailwindcssPackageDir, t as WeappTailwindcss } from "./webpack-
|
|
1
|
+
import { n as weappTailwindcssPackageDir, t as WeappTailwindcss } from "./webpack-2s-TFhgm.mjs";
|
|
2
2
|
export { WeappTailwindcss, WeappTailwindcss as weappTailwindcss, weappTailwindcssPackageDir };
|