weapp-tailwindcss 5.1.9 → 5.1.10
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/shared/generator-css/generation-helpers.d.ts +1 -0
- package/dist/bundlers/shared/generator-css/output-import-shell.d.ts +4 -0
- package/dist/bundlers/shared/generator-css/source-resolver/metadata.d.ts +1 -0
- package/dist/bundlers/shared/generator-css/types.d.ts +2 -0
- package/dist/bundlers/vite/generate-bundle/css-assets.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle/remembered-css-replay.d.ts +2 -0
- package/dist/bundlers/vite/generate-bundle/scoped-generator.d.ts +1 -0
- package/dist/bundlers/vite/hot-css-modules.d.ts +1 -1
- package/dist/bundlers/vite/source-candidates.d.ts +7 -2
- package/dist/bundlers/vite/web-css-compat.d.ts +3 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/css-source-resolvers.d.ts +9 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers.d.ts +3 -0
- package/dist/cli.js +3 -2
- package/dist/cli.mjs +2 -1
- package/dist/{context-CfXr3hWz.mjs → context-DzkSFEVL.mjs} +4 -4
- package/dist/{context-CRhUs_5e.js → context-y2BGCok4.js} +10 -10
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/generator/options.d.ts +8 -1
- package/dist/{v4-engine-BZP2462H.js → generator-Bz94KTkH.js} +229 -17
- package/dist/{v4-engine-CjjWONB0.mjs → generator-ROzBodj6.mjs} +185 -9
- package/dist/generator.js +7 -8
- package/dist/generator.mjs +1 -2
- package/dist/{gulp-CRjkPsbX.mjs → gulp-BKqMb_Ds.mjs} +4 -4
- package/dist/{gulp-JUfnhOOo.js → gulp-DfOLvYLs.js} +10 -10
- package/dist/gulp.js +1 -1
- package/dist/gulp.mjs +1 -1
- package/dist/{hmr-timing-DcIEXnf8.js → hmr-timing-DOTdH18A.js} +556 -170
- package/dist/{hmr-timing-BecOXMd8.mjs → hmr-timing-DwtYJdwb.mjs} +430 -56
- package/dist/index.js +4 -4
- package/dist/index.mjs +4 -4
- package/dist/postcss.js +2 -3
- package/dist/postcss.mjs +1 -2
- package/dist/presets.js +7 -6
- package/dist/presets.mjs +5 -4
- package/dist/rspack.js +1 -1
- package/dist/rspack.mjs +1 -1
- package/dist/{source-candidate-scan-signature-10tvdJVC.js → source-candidate-scan-signature-BrWuBTjY.js} +34 -6
- package/dist/{source-candidate-scan-signature-DAg8QSgh.mjs → source-candidate-scan-signature-CQ04hiox.mjs} +29 -7
- package/dist/{tailwindcss-BZjZZi60.js → tailwindcss-Dn5DVlkI.js} +55 -47
- package/dist/{tailwindcss-PA2jHHpx.mjs → tailwindcss-hzy_WaC9.mjs} +14 -6
- package/dist/{transform-wNEbcZeQ.mjs → transform-BgnNYkIG.mjs} +1 -1
- package/dist/{transform-B0BxX3XB.js → transform-DZQETx51.js} +1 -1
- package/dist/{vite-ClpyoD9e.mjs → vite-BimHmlSp.mjs} +824 -207
- package/dist/{vite-CHk7V9EA.js → vite-bztpcI8_.js} +871 -254
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.js +613 -63
- package/dist/{webpack-2s-TFhgm.mjs → webpack-CCapGlNg.mjs} +235 -38
- package/dist/{webpack-BhM4Hqla.js → webpack-XxBCIrBp.js} +276 -79
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +6 -6
- package/dist/generator-DaaFxR5V.js +0 -174
- package/dist/generator-DugIHBgl.mjs +0 -127
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { o as resolveRuntimeBranch } from "./generator-DugIHBgl.mjs";
|
|
1
|
+
import { F as removeTailwindV4GeneratorAtRules, G as stripMiniProgramCssSpecificityPlaceholders, N as removeMiniProgramHoverSelectors, Ot as resolveSourceScanPath, P as removeTailwindV4GeneratedUserCssArtifacts, R as stripTailwindSourceMediaFragments, T as resolveTailwindcssOptions, U as pruneMiniProgramGeneratedCss, V as finalizeMiniProgramCss, X as hasTailwindSourceDirectives, Y as hasTailwindRootDirectives, Z as normalizeTailwindConfigDirectives, _t as getTailwindV4IncrementalGenerateCacheStats, et as parseImportRequest, h as upsertTailwindV4CssSource, i as normalizeWeappTailwindcssGeneratorOptions, j as isCommentOnlyCss, m as hasConfiguredTailwindV4CssRoots, o as resolveRuntimeBranch, ot as hasTailwindGeneratedCss, q as hasTailwindApplyDirective, st as hasTailwindGeneratedCssMarkers, tt as removeTailwindSourceDirectives, z as stripUnmatchedTailwindSourceMediaCloseFragments } from "./generator-ROzBodj6.mjs";
|
|
3
2
|
import { r as getGroupedEntries } from "./utils-DodxWHGz.mjs";
|
|
4
|
-
import { S as createDebug, b as ensureRuntimeClassSet, f as _defineProperty, i as pluginName, l as shouldSkipJsTransform, n as normalizeStyleHandlerMajorVersion, r as resolveStyleOptionsFromContext, t as getCompilerContext, w as md5Hash, x as refreshTailwindRuntimeState, y as createTailwindRuntimeReadyPromise } from "./context-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { A as
|
|
3
|
+
import { S as createDebug, b as ensureRuntimeClassSet, f as _defineProperty, i as pluginName, l as shouldSkipJsTransform, n as normalizeStyleHandlerMajorVersion, r as resolveStyleOptionsFromContext, t as getCompilerContext, w as md5Hash, x as refreshTailwindRuntimeState, y as createTailwindRuntimeReadyPromise } from "./context-DzkSFEVL.mjs";
|
|
4
|
+
import { n as getDefaultCssPreflight } from "./defaults-9B6aMyZb.mjs";
|
|
5
|
+
import { g as resolveTailwindV4EntriesFromCssCached, l as getRuntimeClassSetSignature, p as resolveViteSourceScanEntries } from "./tailwindcss-hzy_WaC9.mjs";
|
|
6
|
+
import { A as processCachedTask, C as removeGeneratedSelectorCompatCss, D as createCssSourceTraceCacheSignature, E as annotateCssSourceTrace, O as createCssTokenSourceMap, S as scoreTailwindV4CssSourceFileMatch, T as hasMiniProgramTailwindV4PreflightReset, a as isSourceCandidateRequest, c as collectStrictEscapedRuntimeCandidates, f as pushConcurrentTaskFactories, i as createSourceCandidateStore, k as isCssSourceTraceEnabled, l as createEscapeFragments, n as emitHmrTiming, o as resolveSourceCandidateScanFiles, p as resolveTaskConcurrency, s as createBundleRuntimeClassSetManager, w as createCssSourceOrderAppend, y as isPureLocalCssImportWrapper } from "./hmr-timing-DwtYJdwb.mjs";
|
|
7
|
+
import { E as stripRequestQuery, F as resolvePluginDisabledState, L as createBuiltinWebpackStyleInjectorPlugin, N as stripBundlerGeneratedCssMarkers, O as resolveOutputSpecifier, P as resolvePackageDir, T as isSourceStyleRequest, V as resolveWebpackFrameworkProfile, a as createCandidateSignature, f as classifyBundleEntry, j as hasBundlerGeneratedCssMarker, k as toAbsoluteOutputPath, m as updateBundleBuildState, p as createBundleBuildState, r as createScopedGeneratorRuntime, t as createSourceCandidateScanSignature, w as generateTailwindV4Css, x as createRuntimeAffectingSourceSignature, z as webpackStyleInjectorDelegates } from "./source-candidate-scan-signature-CQ04hiox.mjs";
|
|
8
8
|
import Module, { createRequire } from "node:module";
|
|
9
9
|
import fs from "node:fs";
|
|
10
10
|
import path from "node:path";
|
|
@@ -143,6 +143,99 @@ function isWebpackCssLoaderRuntimeSource(source) {
|
|
|
143
143
|
//#endregion
|
|
144
144
|
//#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers.ts
|
|
145
145
|
const WEBPACK_CSS_HANDLER_OPTIONS_CACHE_MAX = 128;
|
|
146
|
+
function resolveConfiguredWebpackCssPreflight(compilerOptions, styleOptions) {
|
|
147
|
+
return styleOptions.cssPreflight ?? compilerOptions.cssPreflight ?? getDefaultCssPreflight();
|
|
148
|
+
}
|
|
149
|
+
function resolveExistingWebpackCssPreflight(compilerOptions, styleOptions, source) {
|
|
150
|
+
return hasMiniProgramPreflightSelector(source) ? resolveConfiguredWebpackCssPreflight(compilerOptions, styleOptions) : void 0;
|
|
151
|
+
}
|
|
152
|
+
function removeMiniProgramPreflightSelectorRule(source) {
|
|
153
|
+
try {
|
|
154
|
+
const root = postcss.parse(source);
|
|
155
|
+
let changed = false;
|
|
156
|
+
root.walkRules((rule) => {
|
|
157
|
+
const selectors = new Set((rule.selectors ?? [rule.selector]).map((selector) => selector.trim().replace(/^:before$/, "::before").replace(/^:after$/, "::after")));
|
|
158
|
+
if (selectors.has("view") && selectors.has("text") && selectors.has("::before") && selectors.has("::after")) {
|
|
159
|
+
rule.remove();
|
|
160
|
+
changed = true;
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
return changed ? root.toString() : source;
|
|
164
|
+
} catch {
|
|
165
|
+
return source.replace(/(?:^|[}\s])\s*view\s*,\s*text\s*,\s*::after\s*,\s*::before\s*\{[^}]*\}/g, "");
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
function dedupeMiniProgramPreflightSelectorRules(source) {
|
|
169
|
+
try {
|
|
170
|
+
const root = postcss.parse(source);
|
|
171
|
+
let firstRule;
|
|
172
|
+
let changed = false;
|
|
173
|
+
root.walkRules((rule) => {
|
|
174
|
+
const selectors = new Set((rule.selectors ?? [rule.selector]).map((selector) => selector.trim().replace(/^:before$/, "::before").replace(/^:after$/, "::after")));
|
|
175
|
+
if (!selectors.has("view") || !selectors.has("text") || !selectors.has("::before") || !selectors.has("::after")) return;
|
|
176
|
+
if (!firstRule) {
|
|
177
|
+
firstRule = rule;
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
const existingProps = /* @__PURE__ */ new Set();
|
|
181
|
+
firstRule.walkDecls((decl) => {
|
|
182
|
+
existingProps.add(decl.prop);
|
|
183
|
+
});
|
|
184
|
+
rule.walkDecls((decl) => {
|
|
185
|
+
if (!existingProps.has(decl.prop)) {
|
|
186
|
+
firstRule?.append(decl.clone());
|
|
187
|
+
existingProps.add(decl.prop);
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
rule.remove();
|
|
191
|
+
changed = true;
|
|
192
|
+
});
|
|
193
|
+
return changed ? root.toString() : source;
|
|
194
|
+
} catch {
|
|
195
|
+
return source;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
function hasMiniProgramPreflightSelector(source) {
|
|
199
|
+
try {
|
|
200
|
+
let found = false;
|
|
201
|
+
postcss.parse(source).walkRules((rule) => {
|
|
202
|
+
const selectors = new Set((rule.selectors ?? [rule.selector]).map((selector) => selector.trim().replace(/^:before$/, "::before").replace(/^:after$/, "::after")));
|
|
203
|
+
if (selectors.has("view") && selectors.has("text") && selectors.has("::before") && selectors.has("::after")) {
|
|
204
|
+
found = true;
|
|
205
|
+
return false;
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
return found;
|
|
209
|
+
} catch {
|
|
210
|
+
return /(?:^|[},])\s*view\s*,\s*text\s*,\s*::after\s*,\s*::before\s*\{/.test(source);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
function ensureWebpackMiniProgramTwContentInit(source) {
|
|
214
|
+
if (!source.includes("var(--tw-content)")) return source;
|
|
215
|
+
try {
|
|
216
|
+
const root = postcss.parse(source);
|
|
217
|
+
let changed = false;
|
|
218
|
+
root.walkRules((rule) => {
|
|
219
|
+
const selectors = new Set((rule.selectors ?? [rule.selector]).map((selector) => selector.trim().replace(/^:before$/, "::before").replace(/^:after$/, "::after")));
|
|
220
|
+
if (!selectors.has("view") || !selectors.has("text") || !selectors.has("::before") || !selectors.has("::after")) return;
|
|
221
|
+
let hasContentInit = false;
|
|
222
|
+
rule.walkDecls("--tw-content", () => {
|
|
223
|
+
hasContentInit = true;
|
|
224
|
+
});
|
|
225
|
+
if (!hasContentInit) {
|
|
226
|
+
rule.append(postcss.decl({
|
|
227
|
+
prop: "--tw-content",
|
|
228
|
+
value: "''"
|
|
229
|
+
}));
|
|
230
|
+
changed = true;
|
|
231
|
+
}
|
|
232
|
+
return false;
|
|
233
|
+
});
|
|
234
|
+
return changed ? root.toString() : source;
|
|
235
|
+
} catch {
|
|
236
|
+
return source;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
146
239
|
function removeTailwindV4StandaloneHostPreflightRule(source) {
|
|
147
240
|
if (!source.includes("--theme(")) return source;
|
|
148
241
|
try {
|
|
@@ -678,7 +771,7 @@ function finalizeMiniProgramUserCssAssetSource(source, compilerOptions, isWebGen
|
|
|
678
771
|
const styleOptions = resolveStyleOptionsFromContext(compilerOptions);
|
|
679
772
|
if (isWebGeneratorTarget) return source;
|
|
680
773
|
return stripMiniProgramCssSpecificityPlaceholders(removeTailwindV4StandaloneHostPreflightRule(finalizeMiniProgramCss(removeMiniProgramHoverSelectors(source, styleOptions.cssRemoveHoverPseudoClass), {
|
|
681
|
-
cssPreflight: options.cssPreflight === false ? false : !hasMiniProgramTailwindV4PreflightReset(source) ? compilerOptions
|
|
774
|
+
cssPreflight: options.cssPreflight === false ? false : !hasMiniProgramTailwindV4PreflightReset(source) ? resolveConfiguredWebpackCssPreflight(compilerOptions, styleOptions) : void 0,
|
|
682
775
|
isTailwindcssV4: true,
|
|
683
776
|
tailwindcssV4GradientFallback: styleOptions.tailwindcssV4GradientFallback
|
|
684
777
|
})));
|
|
@@ -743,9 +836,10 @@ function createWebpackCurrentAssetUserRawSource(options) {
|
|
|
743
836
|
};
|
|
744
837
|
}
|
|
745
838
|
function finalizeTracedWebpackCssAsset(css, cssHandlerOptions, options) {
|
|
746
|
-
|
|
747
|
-
if (options.isWebGeneratorTarget || !isCssSourceTraceEnabled(options.compilerOptions)) return
|
|
748
|
-
|
|
839
|
+
if (options.finalized === true) return options.annotateCss(css);
|
|
840
|
+
if (options.isWebGeneratorTarget || !isCssSourceTraceEnabled(options.compilerOptions)) return options.annotateCss(css);
|
|
841
|
+
const finalized = finalizeMiniProgramUserCssAssetSource(css, options.compilerOptions, options.isWebGeneratorTarget, { cssPreflight: shouldInjectWebpackCssTracePreflight(options.compilerOptions.appType, cssHandlerOptions) });
|
|
842
|
+
return options.annotateCss(finalized);
|
|
749
843
|
}
|
|
750
844
|
function finalizeWebpackCssAssetSource(source, compilerOptions, isWebGeneratorTarget, options = {}) {
|
|
751
845
|
const styleOptions = resolveStyleOptionsFromContext(compilerOptions);
|
|
@@ -754,17 +848,36 @@ function finalizeWebpackCssAssetSource(source, compilerOptions, isWebGeneratorTa
|
|
|
754
848
|
return stripTrailingLineWhitespace(stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(removeTailwindV4GeneratorAtRules(removeTailwindSourceDirectives(stripBundlerGeneratedCssMarkers(source), { importFallback: true })))));
|
|
755
849
|
}
|
|
756
850
|
let finalized = removeTailwindSourceDirectives(stripBundlerGeneratedCssMarkers(source), { importFallback: true });
|
|
757
|
-
if (options.generatedCss !== true)
|
|
851
|
+
if (options.generatedCss !== true) {
|
|
852
|
+
finalized = finalizeMiniProgramCss(finalized, {
|
|
853
|
+
cssPreflight: false,
|
|
854
|
+
isTailwindcssV4: true,
|
|
855
|
+
tailwindcssV4GradientFallback: styleOptions.tailwindcssV4GradientFallback
|
|
856
|
+
});
|
|
857
|
+
finalized = dedupeMiniProgramPreflightSelectorRules(finalized);
|
|
858
|
+
return stripMiniProgramCssSpecificityPlaceholders(removeMiniProgramHoverSelectors(finalized, styleOptions.cssRemoveHoverPseudoClass));
|
|
859
|
+
}
|
|
758
860
|
try {
|
|
759
861
|
finalized = pruneMiniProgramGeneratedCss(finalized, { preservePreflight: options.cssPreflight !== false });
|
|
760
862
|
} catch {}
|
|
863
|
+
const shouldRemoveExistingPreflight = options.cssPreflight === false && options.preserveExistingPreflight === false;
|
|
864
|
+
if (shouldRemoveExistingPreflight) finalized = removeMiniProgramPreflightSelectorRule(finalized);
|
|
865
|
+
const hasExistingMiniProgramPreflight = options.preserveExistingPreflight !== false && hasMiniProgramPreflightSelector(source);
|
|
761
866
|
finalized = finalizeMiniProgramCss(finalized, {
|
|
762
|
-
cssPreflight: options.cssPreflight === false ? false : !hasMiniProgramTailwindV4PreflightReset(finalized) ? compilerOptions
|
|
867
|
+
cssPreflight: options.cssPreflight === false && !hasExistingMiniProgramPreflight ? false : !hasMiniProgramTailwindV4PreflightReset(finalized) ? resolveExistingWebpackCssPreflight(compilerOptions, styleOptions, source) : void 0,
|
|
763
868
|
isTailwindcssV4: true,
|
|
764
869
|
tailwindcssV4GradientFallback: styleOptions.tailwindcssV4GradientFallback
|
|
765
870
|
});
|
|
871
|
+
finalized = ensureWebpackMiniProgramTwContentInit(finalized);
|
|
872
|
+
if (shouldRemoveExistingPreflight) finalized = removeMiniProgramPreflightSelectorRule(finalized);
|
|
873
|
+
else finalized = dedupeMiniProgramPreflightSelectorRules(finalized);
|
|
766
874
|
return stripMiniProgramCssSpecificityPlaceholders(removeMiniProgramHoverSelectors(finalized, styleOptions.cssRemoveHoverPseudoClass));
|
|
767
875
|
}
|
|
876
|
+
function finalizeWebpackCssAssetOutputSource(source, compilerOptions, isWebGeneratorTarget) {
|
|
877
|
+
if (isWebGeneratorTarget) return source;
|
|
878
|
+
const styleOptions = resolveStyleOptionsFromContext(compilerOptions);
|
|
879
|
+
return stripMiniProgramCssSpecificityPlaceholders(removeMiniProgramHoverSelectors(dedupeMiniProgramPreflightSelectorRules(source), styleOptions.cssRemoveHoverPseudoClass));
|
|
880
|
+
}
|
|
768
881
|
function collectWebpackJsRuntimeCandidatesFromAssets(options) {
|
|
769
882
|
if (options.isWebGeneratorTarget) return;
|
|
770
883
|
const candidates = /* @__PURE__ */ new Set();
|
|
@@ -824,8 +937,37 @@ function collectWebpackCssTokenSourceRefs(source) {
|
|
|
824
937
|
}
|
|
825
938
|
return refs;
|
|
826
939
|
}
|
|
940
|
+
function readWebpackCompilationAssetSource(compilation, file) {
|
|
941
|
+
const source = compilation.getAsset?.(file)?.source?.source?.();
|
|
942
|
+
if (source === void 0) return;
|
|
943
|
+
return typeof source === "string" ? source : source.toString();
|
|
944
|
+
}
|
|
945
|
+
function resolveWebpackCssImportFile(file, request) {
|
|
946
|
+
if (/^(?:https?:)?\/\//i.test(request) || request.startsWith("/")) return;
|
|
947
|
+
if (!/\.(?:css|wxss|acss|ttss|qss|jxss|tyss)(?:$|[?#])/i.test(request)) return;
|
|
948
|
+
const cleanRequest = request.replace(/[?#].*$/, "");
|
|
949
|
+
return normalizeWebpackCssSourceRef(path.posix.join(path.posix.dirname(normalizeWebpackCssSourceRef(file)), cleanRequest));
|
|
950
|
+
}
|
|
951
|
+
function collectCssImportRequests(source) {
|
|
952
|
+
return [...source.matchAll(/@import\s+(?:url\(\s*)?(?:"([^"]+)"|'([^']+)'|([^\s;)]+))/g)].map((match) => match[1] ?? match[2] ?? match[3]).filter((request) => typeof request === "string" && request.length > 0);
|
|
953
|
+
}
|
|
954
|
+
function collectMainImportedCssFiles(compilation, cssAssetFiles, cssMatcher, isMainCssFile) {
|
|
955
|
+
const files = /* @__PURE__ */ new Set();
|
|
956
|
+
const candidates = new Set(cssAssetFiles);
|
|
957
|
+
for (const chunk of compilation.chunks) for (const file of chunk.files ?? []) candidates.add(file);
|
|
958
|
+
for (const file of candidates) {
|
|
959
|
+
if (!cssMatcher(file) || !isMainCssFile(file)) continue;
|
|
960
|
+
const source = readWebpackCompilationAssetSource(compilation, file);
|
|
961
|
+
if (!source?.includes("@import")) continue;
|
|
962
|
+
for (const request of collectCssImportRequests(source)) {
|
|
963
|
+
const importedFile = resolveWebpackCssImportFile(file, request);
|
|
964
|
+
if (importedFile) files.add(importedFile);
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
return files;
|
|
968
|
+
}
|
|
827
969
|
function createWebpackCssSourceResolvers(options) {
|
|
828
|
-
const { activeWebpackAssetResourceFiles, appType, compilerOptions, compilation, cssAssetResources, cssHandlerOptionsCache, cssSources, cssUserHandlerOptionsCache, groupedCssEntriesLength, singleCssAssetFile, isWebGeneratorTarget, outputDir, runtimeState } = options;
|
|
970
|
+
const { activeWebpackAssetResourceFiles, appType, compilerOptions, compilation, cssAssetFiles, cssAssetResources, cssHandlerOptionsCache, cssSources, cssUserHandlerOptionsCache, groupedCssEntriesLength, singleCssAssetFile, isWebGeneratorTarget, outputDir, runtimeState } = options;
|
|
829
971
|
const hasConfiguredTailwindV4SourceRoots = () => {
|
|
830
972
|
const tailwindOptions = resolveTailwindcssOptions(runtimeState.tailwindRuntime.options);
|
|
831
973
|
return (tailwindOptions?.v4?.cssEntries?.length ?? 0) > 0 || (tailwindOptions?.v4?.cssSources?.length ?? 0) > 0;
|
|
@@ -836,10 +978,21 @@ function createWebpackCssSourceResolvers(options) {
|
|
|
836
978
|
return [...new Set(entries)];
|
|
837
979
|
})();
|
|
838
980
|
const configuredMainCssEntryFiles = configuredCssEntryFiles.slice(0, 1);
|
|
839
|
-
const
|
|
981
|
+
const scoreCssSourceOutputMatch = (file, sourceFile) => scoreTailwindV4CssSourceFileMatch(file, sourceFile, {
|
|
982
|
+
outputRoot: outputDir,
|
|
983
|
+
projectRoot: compilerOptions.tailwindcssBasedir,
|
|
984
|
+
cwd: compilerOptions.tailwindcssBasedir
|
|
985
|
+
});
|
|
986
|
+
const isConfiguredMainCssEntryFile = (sourceFile) => configuredMainCssEntryFiles.some((entry) => path.resolve(entry) === path.resolve(sourceFile));
|
|
987
|
+
const isCssSourceAllowedForOutput = (file, sourceFile) => !isConfiguredMainCssEntryFile(sourceFile) || scoreCssSourceOutputMatch(file, sourceFile) > 0;
|
|
988
|
+
const inferredMainCssFiles = new Set([...inferWebpackMainCssFiles(compilation.chunks, compilerOptions.cssMatcher, {
|
|
840
989
|
mainSourceFiles: new Set(configuredMainCssEntryFiles),
|
|
841
990
|
resourcesByAsset: cssAssetResources
|
|
842
|
-
})
|
|
991
|
+
})].filter((file) => {
|
|
992
|
+
if (configuredMainCssEntryFiles.length === 0) return true;
|
|
993
|
+
return [...cssAssetResources.get(file) ?? []].some((resource) => isConfiguredMainCssEntryFile(resource) && isCssSourceAllowedForOutput(file, resource));
|
|
994
|
+
}));
|
|
995
|
+
const mainImportedCssFiles = collectMainImportedCssFiles(compilation, cssAssetFiles, compilerOptions.cssMatcher, (file) => compilerOptions.mainCssChunkMatcher(file, appType) || inferredMainCssFiles.has(file));
|
|
843
996
|
const singleConfiguredCssAsset = isWebGeneratorTarget && configuredMainCssEntryFiles.length > 0 && groupedCssEntriesLength === 1 ? singleCssAssetFile : void 0;
|
|
844
997
|
const isMainCssChunk = (file) => {
|
|
845
998
|
const resources = cssAssetResources.get(file);
|
|
@@ -848,7 +1001,7 @@ function createWebpackCssSourceResolvers(options) {
|
|
|
848
1001
|
if (index >= 0) return index === 0;
|
|
849
1002
|
}
|
|
850
1003
|
if (configuredCssEntryFiles.length > 1) return false;
|
|
851
|
-
return compilerOptions.mainCssChunkMatcher(file, appType) || inferredMainCssFiles.has(file) || file === singleConfiguredCssAsset;
|
|
1004
|
+
return compilerOptions.mainCssChunkMatcher(file, appType) || inferredMainCssFiles.has(file) || mainImportedCssFiles.has(normalizeWebpackCssSourceRef(file)) || file === singleConfiguredCssAsset;
|
|
852
1005
|
};
|
|
853
1006
|
const activeWebpackCssSourceFiles = /* @__PURE__ */ new Set();
|
|
854
1007
|
const resolveConfiguredMainCssSourceFile = (file) => {
|
|
@@ -864,14 +1017,14 @@ function createWebpackCssSourceResolvers(options) {
|
|
|
864
1017
|
const assetResources = cssAssetResources.get(file);
|
|
865
1018
|
const activeAssetResource = resolveSingleActiveWebpackCssResource(assetResources, activeWebpackAssetResourceFiles);
|
|
866
1019
|
if (cssSources.size === 0) {
|
|
867
|
-
if (activeAssetResource) {
|
|
1020
|
+
if (activeAssetResource && isCssSourceAllowedForOutput(file, activeAssetResource)) {
|
|
868
1021
|
activeWebpackCssSourceFiles.add(activeAssetResource);
|
|
869
1022
|
return activeAssetResource;
|
|
870
1023
|
}
|
|
871
1024
|
if (assetResources && assetResources.size > 0) return;
|
|
872
1025
|
return resolveConfiguredMainCssSourceFile(file);
|
|
873
1026
|
}
|
|
874
|
-
const resourceMatches = [...assetResources ?? []].filter((sourceFile) => cssSources.has(sourceFile)).sort();
|
|
1027
|
+
const resourceMatches = [...assetResources ?? []].filter((sourceFile) => cssSources.has(sourceFile)).filter((sourceFile) => isCssSourceAllowedForOutput(file, sourceFile)).sort();
|
|
875
1028
|
if (resourceMatches.length === 1) {
|
|
876
1029
|
const sourceFile = resourceMatches[0];
|
|
877
1030
|
activeWebpackCssSourceFiles.add(sourceFile);
|
|
@@ -886,7 +1039,7 @@ function createWebpackCssSourceResolvers(options) {
|
|
|
886
1039
|
activeWebpackCssSourceFiles.add(sourceFile);
|
|
887
1040
|
return sourceFile;
|
|
888
1041
|
}
|
|
889
|
-
if (activeAssetResource) {
|
|
1042
|
+
if (activeAssetResource && isCssSourceAllowedForOutput(file, activeAssetResource)) {
|
|
890
1043
|
activeWebpackCssSourceFiles.add(activeAssetResource);
|
|
891
1044
|
return activeAssetResource;
|
|
892
1045
|
}
|
|
@@ -946,8 +1099,10 @@ function createWebpackCssSourceResolvers(options) {
|
|
|
946
1099
|
});
|
|
947
1100
|
const getCssHandlerOptions = (file, rawSource) => {
|
|
948
1101
|
const majorVersion = runtimeState.tailwindRuntime.majorVersion;
|
|
949
|
-
const
|
|
1102
|
+
const isMainCssAsset = isMainCssChunk(file);
|
|
950
1103
|
const sourceFile = resolveWebpackCssSourceFile(file, rawSource);
|
|
1104
|
+
const sourceMatchedMainCssEntry = sourceFile !== void 0 && isConfiguredMainCssEntryFile(sourceFile) && isCssSourceAllowedForOutput(file, sourceFile);
|
|
1105
|
+
const isMainChunk = isMainCssAsset || sourceMatchedMainCssEntry;
|
|
951
1106
|
const sourceCss = sourceFile ? cssSources.get(sourceFile)?.css : void 0;
|
|
952
1107
|
const generatorSourceCss = removeWebpackGeneratorNonTailwindImports(sourceCss);
|
|
953
1108
|
const generatorCssSource = createWebpackGeneratorCssSource(sourceFile, generatorSourceCss);
|
|
@@ -998,6 +1153,7 @@ function createWebpackCssSourceResolvers(options) {
|
|
|
998
1153
|
};
|
|
999
1154
|
return {
|
|
1000
1155
|
activeWebpackCssSourceFiles,
|
|
1156
|
+
configuredCssEntryFiles,
|
|
1001
1157
|
configuredMainCssEntryFiles,
|
|
1002
1158
|
getCssHandlerOptions,
|
|
1003
1159
|
getCssUserHandlerOptions,
|
|
@@ -1367,7 +1523,12 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
1367
1523
|
const { compiler, options: compilerOptions, appType, runtimeState, getRuntimeRefreshRequirement, refreshRuntimeMetadata, isKnownWebpackProcessedCssAsset, isWebpackProcessedCssAsset, consumeRuntimeRefreshRequirement, isWatchMode, getWatchChangedFiles, runtimeClassSetManager, getWebpackCssSources, getWebpackGeneratedCssSources, pruneWebpackCssSources, prepareWebpackCssSources, debug } = options;
|
|
1368
1524
|
const { Compilation, sources } = compiler.webpack;
|
|
1369
1525
|
const { ConcatSource } = sources;
|
|
1370
|
-
const isWebGeneratorTarget = compilerOptions.generator
|
|
1526
|
+
const isWebGeneratorTarget = normalizeWeappTailwindcssGeneratorOptions(compilerOptions.generator, {
|
|
1527
|
+
appType: compilerOptions.appType,
|
|
1528
|
+
platform: compilerOptions.cssOptions?.platform ?? compilerOptions.platform,
|
|
1529
|
+
tailwindcssMajorVersion: runtimeState.tailwindRuntime.majorVersion,
|
|
1530
|
+
uniAppX: compilerOptions.uniAppX
|
|
1531
|
+
}).target === "web";
|
|
1371
1532
|
const cssHandlerOptionsCache = /* @__PURE__ */ new Map();
|
|
1372
1533
|
const cssUserHandlerOptionsCache = /* @__PURE__ */ new Map();
|
|
1373
1534
|
const webpackSourceCandidateScanCache = createWebpackSourceCandidateScanCache();
|
|
@@ -1423,11 +1584,12 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
1423
1584
|
for (const chunk of compilation.chunks) if (chunk.id) activeProcessHashKeys.add(chunk.id);
|
|
1424
1585
|
const cssSources = new Map([...getWebpackCssSources?.() ?? []].map(([file, source]) => [path.resolve(file), source]));
|
|
1425
1586
|
const generatedCssSources = new Map([...getWebpackGeneratedCssSources?.() ?? []].map(([file, source]) => [path.resolve(file), source]));
|
|
1426
|
-
const { activeWebpackCssSourceFiles, configuredMainCssEntryFiles, getCssHandlerOptions, getCssUserHandlerOptions, hasConfiguredTailwindV4SourceRoots, isSameWebpackSourceScope, resolveWebpackCssSourceFile } = createWebpackCssSourceResolvers({
|
|
1587
|
+
const { activeWebpackCssSourceFiles, configuredCssEntryFiles, configuredMainCssEntryFiles, getCssHandlerOptions, getCssUserHandlerOptions, hasConfiguredTailwindV4SourceRoots, isSameWebpackSourceScope, resolveWebpackCssSourceFile } = createWebpackCssSourceResolvers({
|
|
1427
1588
|
activeWebpackAssetResourceFiles,
|
|
1428
1589
|
appType,
|
|
1429
1590
|
compilerOptions,
|
|
1430
1591
|
compilation,
|
|
1592
|
+
cssAssetFiles: entries.map(([file]) => file),
|
|
1431
1593
|
cssAssetResources,
|
|
1432
1594
|
cssHandlerOptionsCache,
|
|
1433
1595
|
cssSources,
|
|
@@ -1455,9 +1617,10 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
1455
1617
|
opts: compilerOptions,
|
|
1456
1618
|
tokenSources: cssSourceTraceTokenSources
|
|
1457
1619
|
});
|
|
1458
|
-
const finalizeTracedCss = (css, cssHandlerOptions) => finalizeTracedWebpackCssAsset(css, cssHandlerOptions, {
|
|
1620
|
+
const finalizeTracedCss = (css, cssHandlerOptions, options = {}) => finalizeTracedWebpackCssAsset(css, cssHandlerOptions, {
|
|
1459
1621
|
annotateCss,
|
|
1460
1622
|
compilerOptions,
|
|
1623
|
+
...options,
|
|
1461
1624
|
isWebGeneratorTarget
|
|
1462
1625
|
});
|
|
1463
1626
|
const hasRuntimeTransformAssets = Boolean(!isWebGeneratorTarget && ((groupedEntries.html?.length ?? 0) > 0 || (groupedEntries.js?.length ?? 0) > 0));
|
|
@@ -1749,7 +1912,7 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
1749
1912
|
processed: true
|
|
1750
1913
|
}).css;
|
|
1751
1914
|
debug("css skip webpack-loader-pipeline asset: %s", file);
|
|
1752
|
-
return { result: new ConcatSource(finalizeTracedCss(css, cssHandlerOptionsForProcessedAsset)) };
|
|
1915
|
+
return { result: new ConcatSource(finalizeTracedCss(css, cssHandlerOptionsForProcessedAsset, { finalized: true })) };
|
|
1753
1916
|
}
|
|
1754
1917
|
});
|
|
1755
1918
|
}, cssTaskFactories);
|
|
@@ -1815,8 +1978,12 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
1815
1978
|
const generatorRawSource = resolveWebpackGeneratorRawSource(currentRawSource, cssHandlerOptions);
|
|
1816
1979
|
if (isWebpackCssLoaderRuntimeSource(generatorRawSource)) return { result: new ConcatSource(currentRawSource) };
|
|
1817
1980
|
const sourceFile = cssHandlerOptions.sourceOptions?.sourceFile;
|
|
1818
|
-
const loaderGeneratedCss = sourceFile && !isWebGeneratorTarget ? generatedCssSources.get(path.resolve(sourceFile)) : void 0;
|
|
1819
1981
|
const sourceCss = sourceFile ? cssSources.get(path.resolve(sourceFile))?.css : void 0;
|
|
1982
|
+
const isConfiguredCssSource = sourceFile !== void 0 && configuredCssEntryFiles.some((entry) => path.resolve(entry) === path.resolve(sourceFile));
|
|
1983
|
+
const isConfiguredMainCssSource = sourceFile !== void 0 && configuredMainCssEntryFiles.some((entry) => path.resolve(entry) === path.resolve(sourceFile));
|
|
1984
|
+
const sourceCssHasTailwindRoot = sourceCss !== void 0 && hasTailwindRootDirectives(sourceCss, { importFallback: true });
|
|
1985
|
+
const shouldPreserveExistingPreflight = cssHandlerOptions.isMainChunk || !isConfiguredMainCssSource && (isConfiguredCssSource || sourceCssHasTailwindRoot);
|
|
1986
|
+
const loaderGeneratedCss = sourceFile && !isWebGeneratorTarget ? generatedCssSources.get(path.resolve(sourceFile)) : void 0;
|
|
1820
1987
|
const shouldRegenerateExplicitTailwindV4CssSource = sourceCss !== void 0 && (hasTailwindSourceDirectives(sourceCss, { importFallback: true }) || sourceCss.includes("@config"));
|
|
1821
1988
|
const explicitTailwindV4SourceCandidates = shouldRegenerateExplicitTailwindV4CssSource && sourceCss && sourceFile && webpackSourceCandidates?.getSourceCandidatesForEntries ? await resolveTailwindV4EntriesFromCssCached(sourceCss, path.dirname(sourceFile)).then((resolved) => resolved?.entries ? webpackSourceCandidates.getSourceCandidatesForEntries(resolved.entries) : void 0) : void 0;
|
|
1822
1989
|
if (loaderGeneratedCss && shouldConsumeWebpackLoaderGeneratedCss({
|
|
@@ -1834,13 +2001,15 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
1834
2001
|
const currentRawSourceWithoutBundlerMarkers = stripBundlerGeneratedCssMarkers(currentRawSource);
|
|
1835
2002
|
const currentAssetHasProcessedUrl = hasProcessedCssAssetUrl(currentRawSourceWithoutBundlerMarkers) && currentRawSourceWithoutBundlerMarkers !== loaderGeneratedCss.css;
|
|
1836
2003
|
const currentAssetUserCss = currentAssetHasProcessedUrl ? currentRawSourceWithoutBundlerMarkers : shouldUseWebpackAssetAsGeneratorUserCss(currentRawSourceWithoutBundlerMarkers, loaderGeneratedCss.css, { processed: true }) ? removeGeneratedSelectorCompatCss(currentRawSourceWithoutBundlerMarkers, loaderGeneratedCss.css) : void 0;
|
|
1837
|
-
const isConfiguredMainCssSource = configuredMainCssEntryFiles.some((entry) => path.resolve(entry) === path.resolve(sourceFile));
|
|
1838
2004
|
const loaderGeneratedCssWithoutMarkers = stripBundlerGeneratedCssMarkers(loaderGeneratedCss.css);
|
|
1839
2005
|
const currentAssetUserCssWithoutMarkers = currentAssetUserCss === void 0 ? "" : stripBundlerGeneratedCssMarkers(currentAssetUserCss);
|
|
1840
2006
|
const currentAssetMissingUserCss = !(currentAssetUserCssWithoutMarkers.trim().length > 0 && !isCommentOnlyCss(currentAssetUserCssWithoutMarkers)) ? "" : filterExistingCssRules(currentAssetUserCssWithoutMarkers, loaderGeneratedCssWithoutMarkers);
|
|
1841
|
-
if (isConfiguredMainCssSource && !cssHandlerOptions.isMainChunk
|
|
2007
|
+
if (isConfiguredMainCssSource && !cssHandlerOptions.isMainChunk) {
|
|
1842
2008
|
debug("css skip duplicate webpack loader main generation: %s <- %s", file, sourceFile);
|
|
1843
|
-
return { result: new ConcatSource(finalizeTracedCss("",
|
|
2009
|
+
return { result: new ConcatSource(finalizeTracedCss(currentAssetMissingUserCss.trim().length === 0 || isCommentOnlyCss(currentAssetMissingUserCss) ? "" : finalizeCssAssetSource(currentAssetMissingUserCss, {
|
|
2010
|
+
cssPreflight: false,
|
|
2011
|
+
generatedCss: false
|
|
2012
|
+
}), cssHandlerOptions)) };
|
|
1844
2013
|
}
|
|
1845
2014
|
const finalizedLoaderCss = finalizeCssAssetSource(currentAssetUserCss === void 0 ? loaderGeneratedCss.css : createWebpackGeneratorUserCssSourceAppend({
|
|
1846
2015
|
css: currentAssetUserCss === void 0 ? loaderGeneratedCss.css : currentAssetHasProcessedUrl ? removeGeneratedSelectorCompatCss(loaderGeneratedCss.css, currentAssetUserCss) : filterExistingCssRules(currentAssetUserCss, loaderGeneratedCss.css),
|
|
@@ -1850,7 +2019,8 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
1850
2019
|
processed: true
|
|
1851
2020
|
}).css, {
|
|
1852
2021
|
cssPreflight: cssHandlerOptions.isMainChunk,
|
|
1853
|
-
generatedCss: true
|
|
2022
|
+
generatedCss: true,
|
|
2023
|
+
preserveExistingPreflight: shouldPreserveExistingPreflight
|
|
1854
2024
|
});
|
|
1855
2025
|
const loaderSourceBareUserCss = isWebGeneratorTarget ? void 0 : createWebpackGeneratorUserCssSourceAppend(...[currentAssetUserCss === void 0 ? void 0 : {
|
|
1856
2026
|
css: currentAssetUserCss,
|
|
@@ -1876,7 +2046,7 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
1876
2046
|
}, {
|
|
1877
2047
|
css: missingLoaderSourceBareUserCss,
|
|
1878
2048
|
processed: true
|
|
1879
|
-
}).css, cssHandlerOptions);
|
|
2049
|
+
}).css, cssHandlerOptions, { finalized: true });
|
|
1880
2050
|
debug("css consume webpack loader generation: %s <- %s", file, sourceFile);
|
|
1881
2051
|
return { result: new ConcatSource(css) };
|
|
1882
2052
|
}
|
|
@@ -1888,6 +2058,7 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
1888
2058
|
const currentAssetLooksGenerated = hasTailwindGeneratedCss(currentRawSource) || hasTailwindGeneratedCssMarkers(currentRawSource);
|
|
1889
2059
|
const currentAssetHasBundlerGeneratedMarker = hasBundlerGeneratedCssMarker(currentRawSource);
|
|
1890
2060
|
const currentAssetUserCssSource = currentAssetLooksGenerated ? removeWebpackTailwindGeneratedAssetCss(currentRawSource) : currentRawSource;
|
|
2061
|
+
if (sourceFile === void 0 && currentAssetHasBundlerGeneratedMarker && (currentAssetUserCssSource.trim().length === 0 || isCommentOnlyCss(currentAssetUserCssSource))) return { result: new ConcatSource(finalizeTracedCss("", cssHandlerOptions)) };
|
|
1891
2062
|
const currentAssetHasAdditionalUserCss = currentAssetLooksGenerated && (hasAdditionalWebpackAssetUserCssMarkers(currentAssetUserCssSource, generatorRawSource) || currentAssetUserCssSource.trim().length > 0);
|
|
1892
2063
|
const shouldPreserveGeneratedWebAssetUserCss = isWebGeneratorTarget && currentAssetLooksGenerated && !currentAssetHasBundlerGeneratedMarker && !currentAssetHasAdditionalUserCss;
|
|
1893
2064
|
const hasExplicitSourceCssForCurrentAsset = sourceCss !== void 0 && (hasTailwindRootDirectives(sourceCss, { importFallback: true }) || hasTailwindSourceDirectives(sourceCss, { importFallback: true }) || hasTailwindApplyDirective(sourceCss));
|
|
@@ -1912,9 +2083,12 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
1912
2083
|
const currentAssetHasTailwindDirectives = hasTailwindRootDirectives(generatorRawSource, { importFallback: true }) || hasTailwindSourceDirectives(generatorRawSource, { importFallback: true }) || hasTailwindApplyDirective(generatorRawSource);
|
|
1913
2084
|
const shouldForceTailwindV4Generation = hasConfiguredTailwindV4SourceRoots() && (configuredMainCssEntryFiles.length > 0 && sourceFile !== void 0 || currentAssetHasTailwindDirectives || hasExplicitTailwindV4SourceCss);
|
|
1914
2085
|
const shouldSkipUnmatchedMainCssGeneration = !isWebGeneratorTarget && cssHandlerOptions.isMainChunk && sourceFile === void 0 && configuredMainCssEntryFiles.length > 0 && !currentAssetHasTailwindDirectives;
|
|
2086
|
+
const shouldSkipPlainNonMainCssGeneration = !cssHandlerOptions.isMainChunk && sourceCss !== void 0 && !hasExplicitSourceCssForCurrentAsset && !hasExplicitTailwindV4SourceCss && !currentAssetHasTailwindDirectives;
|
|
2087
|
+
const shouldMergeFallbackGeneratorRuntime = cssHandlerOptions.isMainChunk || currentAssetHasTailwindDirectives || hasExplicitSourceCssForCurrentAsset;
|
|
2088
|
+
const scopedFallbackGeneratorRuntimeSet = hasExplicitTailwindV4SourceCss || !shouldMergeFallbackGeneratorRuntime ? /* @__PURE__ */ new Set() : fallbackGeneratorRuntimeSet;
|
|
1915
2089
|
const resolvedScopedGeneratorRuntimeSet = await createScopedGeneratorRuntime({
|
|
1916
2090
|
cssHandlerOptions,
|
|
1917
|
-
fallbackRuntime:
|
|
2091
|
+
fallbackRuntime: scopedFallbackGeneratorRuntimeSet,
|
|
1918
2092
|
getSourceCandidatesForEntries: webpackSourceCandidates?.getSourceCandidatesForEntries,
|
|
1919
2093
|
majorVersion: runtimeState.tailwindRuntime.majorVersion,
|
|
1920
2094
|
outputFile: file,
|
|
@@ -1923,7 +2097,7 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
1923
2097
|
sourceFile: sourceFile ?? file,
|
|
1924
2098
|
scopedSourceCandidateGetter: webpackSourceCandidates?.getSourceCandidatesForEntries
|
|
1925
2099
|
});
|
|
1926
|
-
const scopedGeneratorRuntimeSet = !hasExplicitTailwindV4SourceCss && resolvedScopedGeneratorRuntimeSet !==
|
|
2100
|
+
const scopedGeneratorRuntimeSet = !hasExplicitTailwindV4SourceCss && resolvedScopedGeneratorRuntimeSet !== scopedFallbackGeneratorRuntimeSet && shouldMergeFallbackGeneratorRuntime ? /* @__PURE__ */ new Set([...fallbackGeneratorRuntimeSet, ...resolvedScopedGeneratorRuntimeSet]) : resolvedScopedGeneratorRuntimeSet;
|
|
1927
2101
|
const generatorCssSources = normalizeWebpackGeneratorCssSources(cssHandlerOptions.sourceOptions?.cssSources);
|
|
1928
2102
|
const scopedGeneratorCompilerOptions = scopeWebpackGeneratorOptionsToCssSource(compilerOptions, sourceFile, { disableUnmatchedCssEntries: !isWebGeneratorTarget && cssHandlerOptions.isMainChunk });
|
|
1929
2103
|
const generatorCssHandlerOptions = generatorCssSources === void 0 ? cssHandlerOptions : {
|
|
@@ -1952,7 +2126,7 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
1952
2126
|
debug
|
|
1953
2127
|
};
|
|
1954
2128
|
let generated;
|
|
1955
|
-
if (!shouldSkipUnmatchedMainCssGeneration) try {
|
|
2129
|
+
if (!shouldSkipUnmatchedMainCssGeneration && !shouldSkipPlainNonMainCssGeneration) try {
|
|
1956
2130
|
generated = await generateTailwindV4Css({
|
|
1957
2131
|
...generatorOptions,
|
|
1958
2132
|
outputFile: file
|
|
@@ -1966,7 +2140,7 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
1966
2140
|
debug("css generator skipped for plain webpack css asset: %s %O", file, error);
|
|
1967
2141
|
generated = void 0;
|
|
1968
2142
|
}
|
|
1969
|
-
else debug("css generator skipped for
|
|
2143
|
+
else debug("css generator skipped for plain webpack css asset: %s", file);
|
|
1970
2144
|
const finalizedGeneratedCss = generated ? finalizeCssAssetSource(isWebGeneratorTarget && currentRawSource.includes("tailwindcss v4.") ? createWebpackGeneratorUserCssSourceAppend({
|
|
1971
2145
|
css: generated.css,
|
|
1972
2146
|
processed: true
|
|
@@ -1975,7 +2149,8 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
1975
2149
|
processed: true
|
|
1976
2150
|
})?.css ?? generated.css : generated.css, {
|
|
1977
2151
|
cssPreflight: cssHandlerOptions.isMainChunk,
|
|
1978
|
-
generatedCss: true
|
|
2152
|
+
generatedCss: true,
|
|
2153
|
+
preserveExistingPreflight: shouldPreserveExistingPreflight
|
|
1979
2154
|
}) : isWebGeneratorTarget ? finalizeCssAssetSource(generatorRawSource, { generatedCss: false }) : finalizeCssAssetSource((await compilerOptions.styleHandler(generatorRawSource, cssHandlerOptions)).css, { generatedCss: false });
|
|
1980
2155
|
const sourceBareUserCss = isWebGeneratorTarget ? void 0 : createWebpackGeneratorUserCssSourceAppend(...[
|
|
1981
2156
|
userRawSource,
|
|
@@ -2005,7 +2180,7 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
2005
2180
|
}, {
|
|
2006
2181
|
css: missingSourceBareUserCss,
|
|
2007
2182
|
processed: true
|
|
2008
|
-
}).css, cssHandlerOptions));
|
|
2183
|
+
}).css, cssHandlerOptions, { finalized: true }));
|
|
2009
2184
|
if (generated) {
|
|
2010
2185
|
for (const className of generated.classSet) generatorRuntimeSet.add(className);
|
|
2011
2186
|
debug("css handle via tailwind v%s engine(%s): %s", runtimeState.tailwindRuntime.majorVersion, generated.target, file);
|
|
@@ -2050,6 +2225,22 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
2050
2225
|
}) });
|
|
2051
2226
|
compilerOptions.onEnd();
|
|
2052
2227
|
});
|
|
2228
|
+
if (!isWebGeneratorTarget) compilation.hooks.processAssets.tapPromise({
|
|
2229
|
+
name: `${pluginName}:finalize-css-assets`,
|
|
2230
|
+
stage: Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_HASH
|
|
2231
|
+
}, async (assets) => {
|
|
2232
|
+
const entries = Object.entries(assets);
|
|
2233
|
+
if (entries.length === 0) return;
|
|
2234
|
+
const groupedEntries = getGroupedEntries(entries, compilerOptions);
|
|
2235
|
+
if (groupedEntries.css.length === 0) return;
|
|
2236
|
+
const { updateAssetIfChanged } = createWebpackAssetUpdater({
|
|
2237
|
+
compilation,
|
|
2238
|
+
ConcatSource,
|
|
2239
|
+
onUpdate: compilerOptions.onUpdate,
|
|
2240
|
+
debug
|
|
2241
|
+
});
|
|
2242
|
+
for (const [file, asset] of groupedEntries.css) updateAssetIfChanged(file, finalizeWebpackCssAssetOutputSource(stringifyWebpackSourceLike(compilation.getAsset(file)?.source.source() ?? asset.source()), compilerOptions, isWebGeneratorTarget));
|
|
2243
|
+
});
|
|
2053
2244
|
});
|
|
2054
2245
|
}
|
|
2055
2246
|
//#endregion
|
|
@@ -2278,7 +2469,13 @@ function createDefaultLoaderAnchorFinders() {
|
|
|
2278
2469
|
//#region src/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.ts
|
|
2279
2470
|
function setupWebpackV5Loaders(options) {
|
|
2280
2471
|
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
|
-
const
|
|
2472
|
+
const generatorOptions = normalizeWeappTailwindcssGeneratorOptions(compilerOptions.generator, {
|
|
2473
|
+
appType: compilerOptions.appType,
|
|
2474
|
+
platform: compilerOptions.cssOptions?.platform ?? compilerOptions.platform,
|
|
2475
|
+
tailwindcssMajorVersion: runtimeState.tailwindRuntime.majorVersion,
|
|
2476
|
+
uniAppX: compilerOptions.uniAppX
|
|
2477
|
+
});
|
|
2478
|
+
const generatorTarget = generatorOptions.target;
|
|
2282
2479
|
const generatorBranch = resolveRuntimeBranch({
|
|
2283
2480
|
appType: compilerOptions.appType,
|
|
2284
2481
|
generatorTarget,
|
|
@@ -2289,7 +2486,7 @@ function setupWebpackV5Loaders(options) {
|
|
|
2289
2486
|
if (shouldRewriteCssImports && mpxCssImportRewrite) ensureMpxTailwindcssAliases(compiler, weappTailwindcssPackageDir);
|
|
2290
2487
|
const runtimeClassSetLoader = runtimeLoaderPath ?? path.resolve(__dirname, "./weapp-tw-runtime-classset-loader.js");
|
|
2291
2488
|
const shouldInjectRuntimeClassSetLoader = !generatorBranch.isWeb;
|
|
2292
|
-
const shouldInjectCssImportRewriteLoader = shouldRewriteCssImports || !generatorBranch.isWeb || runtimeState.tailwindRuntime.majorVersion === 4;
|
|
2489
|
+
const shouldInjectCssImportRewriteLoader = shouldRewriteCssImports || generatorOptions.enabled && (!generatorBranch.isWeb || runtimeState.tailwindRuntime.majorVersion === 4);
|
|
2293
2490
|
const runtimeCssImportRewriteLoader = shouldInjectCssImportRewriteLoader ? path.resolve(__dirname, "./weapp-tw-css-import-rewrite-loader.js") : void 0;
|
|
2294
2491
|
const runtimeClassSetLoaderExists = fs.existsSync(runtimeClassSetLoader);
|
|
2295
2492
|
const runtimeCssImportRewriteLoaderExists = runtimeCssImportRewriteLoader ? fs.existsSync(runtimeCssImportRewriteLoader) : false;
|