weapp-tailwindcss 5.1.14 → 5.1.15

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 (63) hide show
  1. package/dist/auto-2dg_uhEJ.mjs +13 -0
  2. package/dist/bundlers/gulp/frameworks/native/index.d.ts +2 -0
  3. package/dist/bundlers/gulp/index.d.ts +2 -0
  4. package/dist/bundlers/gulp/shared/create-native-framework-plugins.d.ts +2 -0
  5. package/dist/bundlers/shared/generated-css-marker.d.ts +2 -2
  6. package/dist/bundlers/shared/generator-css/local-imports.d.ts +1 -1
  7. package/dist/bundlers/shared/generator-css/source-resolver/postcss-source.d.ts +2 -0
  8. package/dist/bundlers/shared/generator-css/types.d.ts +5 -0
  9. package/dist/bundlers/shared/style-requests.d.ts +1 -0
  10. package/dist/bundlers/vite/bundle-state.d.ts +1 -0
  11. package/dist/bundlers/vite/generate-bundle/bundle-markup-candidates.d.ts +20 -0
  12. package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +1 -0
  13. package/dist/bundlers/vite/generate-bundle/remembered-css-replay.d.ts +1 -0
  14. package/dist/bundlers/vite/generate-bundle/sfc-style-source.d.ts +2 -1
  15. package/dist/bundlers/vite/generate-bundle/source-candidate-source.d.ts +1 -0
  16. package/dist/bundlers/vite/generate-bundle/types.d.ts +5 -0
  17. package/dist/bundlers/vite/serve-css-generation.d.ts +3 -2
  18. package/dist/bundlers/vite/shared/create-framework-plugins.d.ts +1 -0
  19. package/dist/bundlers/vite/watch-css-post.d.ts +10 -0
  20. package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +6 -0
  21. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/css-source-resolvers.d.ts +1 -0
  22. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers.d.ts +2 -0
  23. package/dist/bundlers/webpack/loaders/runtime-registry.d.ts +1 -0
  24. package/dist/bundlers/webpack/loaders/weapp-tw-css-generation-loader.d.ts +4 -0
  25. package/dist/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.d.ts +3 -0
  26. package/dist/{context-BL8Gy71H.mjs → context-BgGWVAmN.mjs} +2 -2
  27. package/dist/core.mjs +1 -1
  28. package/dist/css-macro.mjs +1 -1
  29. package/dist/{generator-B59OA64h.mjs → generator-CEo920So.mjs} +1 -1
  30. package/dist/generator.mjs +1 -1
  31. package/dist/{gulp-C1Q3LRzg.js → gulp-3m1dAiig.js} +84 -50
  32. package/dist/{gulp-DUYWxmZC.mjs → gulp-DP71z1jG.mjs} +87 -53
  33. package/dist/gulp.js +1 -1
  34. package/dist/gulp.mjs +1 -1
  35. package/dist/{hmr-timing-C3ed5vCx.mjs → hmr-timing-1aS6--U7.mjs} +170 -44
  36. package/dist/{hmr-timing-BZ5sWIqO.js → hmr-timing-B8p4f0ca.js} +219 -39
  37. package/dist/index.js +3 -3
  38. package/dist/index.mjs +4 -4
  39. package/dist/postcss.mjs +1 -1
  40. package/dist/presets.mjs +1 -1
  41. package/dist/rspack.js +1 -1
  42. package/dist/rspack.mjs +1 -1
  43. package/dist/shared/mpx.d.ts +4 -1
  44. package/dist/{source-candidate-scan-signature-R3dzamcm.js → source-candidate-scan-signature-BAahhiwb.js} +4 -96
  45. package/dist/{source-candidate-scan-signature-D7RWjWsY.mjs → source-candidate-scan-signature-Cf7259PR.mjs} +6 -62
  46. package/dist/{tailwindcss-DPcKMLxL.mjs → tailwindcss-xs704TRw.mjs} +1 -1
  47. package/dist/{transform-D5JUgMpE.mjs → transform-B_KM9sLX.mjs} +47 -5
  48. package/dist/{transform-COFRlmDF.js → transform-CcYptivi.js} +47 -5
  49. package/dist/uni-app-x/component-local-style.d.ts +1 -0
  50. package/dist/uni-app-x/style-asset/style-value.d.ts +1 -1
  51. package/dist/{vite-BNlPdsGM.js → vite-DUVjMduj.js} +550 -273
  52. package/dist/{vite-CBU5NXTX.mjs → vite-nXZEiwG0.mjs} +501 -224
  53. package/dist/vite.js +1 -1
  54. package/dist/vite.mjs +1 -1
  55. package/dist/weapp-tw-css-generation-loader.js +12 -0
  56. package/dist/weapp-tw-css-import-rewrite-loader-DNk0IxAt.js +10198 -0
  57. package/dist/weapp-tw-css-import-rewrite-loader.js +6 -10255
  58. package/dist/{webpack-CZ38fMGC.mjs → webpack-C_UUFRgj.mjs} +223 -57
  59. package/dist/{webpack-Jpe048pQ.js → webpack-nppysF4B.js} +232 -66
  60. package/dist/webpack.js +1 -1
  61. package/dist/webpack.mjs +1 -1
  62. package/package.json +11 -3
  63. package/dist/auto-CrJJc5rK.mjs +0 -13
@@ -1,12 +1,12 @@
1
1
  import { resolveImplicitAppTypeFromViteRoot } from "./framework.mjs";
2
- import { At as resolveTailwindV4CssSourceBase, E as resolveTailwindcssOptions, J as hasTailwindApplyDirective, K as stripMiniProgramCssSpecificityPlaceholders, N as normalizeEmptyTailwindCustomVariants, Nt as filterUnsupportedMiniProgramTailwindV4Candidates, Q as normalizeTailwindConfigDirectives, R as splitUserCssLayerBlocks, U as hasMiniProgramCssSpecificityPlaceholders, X as hasTailwindRootDirectives, Y as hasTailwindNonRootGenerationDirectives, Z as hasTailwindSourceDirectives, a as resolveGeneratorRuntimeBranch, b as normalizeCssEntries, c as shouldUseNativeAppCssBranch, ct as hasTailwindGeneratedCssMarkers, et as normalizeTailwindSourceForGenerator, ft as stripGeneratorPlaceholderMarkers, g as upsertTailwindV4CssSource, h as hasConfiguredTailwindV4CssRoots, i as normalizeWeappTailwindcssGeneratorOptions, j as hasUserCssLayerBlocks, l as resolveUniUtsPlatform, m as filterTailwindV4CssSourceRoots, nt as removeTailwindSourceDirectives, q as hasLocalCssImport, s as shouldUseMiniProgramCssBranch, tt as parseImportRequest, vt as getTailwindV4IncrementalGenerateCacheStats, x as findNearestPackageRoot, y as isTailwindV4CssEntry } from "./generator-B59OA64h.mjs";
2
+ import { At as resolveTailwindV4CssSourceBase, E as resolveTailwindcssOptions, J as hasTailwindApplyDirective, K as stripMiniProgramCssSpecificityPlaceholders, N as normalizeEmptyTailwindCustomVariants, Nt as filterUnsupportedMiniProgramTailwindV4Candidates, Q as normalizeTailwindConfigDirectives, R as splitUserCssLayerBlocks, Tt as isFileMatchedByTailwindSourceEntries, U as hasMiniProgramCssSpecificityPlaceholders, X as hasTailwindRootDirectives, Y as hasTailwindNonRootGenerationDirectives, Z as hasTailwindSourceDirectives, a as resolveGeneratorRuntimeBranch, b as normalizeCssEntries, c as shouldUseNativeAppCssBranch, ct as hasTailwindGeneratedCssMarkers, et as normalizeTailwindSourceForGenerator, ft as stripGeneratorPlaceholderMarkers, g as upsertTailwindV4CssSource, h as hasConfiguredTailwindV4CssRoots, i as normalizeWeappTailwindcssGeneratorOptions, j as hasUserCssLayerBlocks, l as resolveUniUtsPlatform, m as filterTailwindV4CssSourceRoots, nt as removeTailwindSourceDirectives, q as hasLocalCssImport, s as shouldUseMiniProgramCssBranch, tt as parseImportRequest, vt as getTailwindV4IncrementalGenerateCacheStats, x as findNearestPackageRoot, y as isTailwindV4CssEntry } from "./generator-CEo920So.mjs";
3
3
  import { t as omitUndefined } from "./object-BJSWl-E5.mjs";
4
- import { _ as resolveViteTailwindV4CssDependencies, a as findTailwindConfig, f as createViteSourceScanMatcher, g as resolveTailwindV4EntriesFromCssCached, i as resolveUniAppXOptions, l as getRuntimeClassSetSignature, m as discoverTailwindV4CssEntries, p as resolveViteSourceScanEntries, r as isUniAppXEnabled } from "./tailwindcss-DPcKMLxL.mjs";
4
+ import { _ as resolveViteTailwindV4CssDependencies, a as findTailwindConfig, f as createViteSourceScanMatcher, g as resolveTailwindV4EntriesFromCssCached, i as resolveUniAppXOptions, l as getRuntimeClassSetSignature, m as discoverTailwindV4CssEntries, p as resolveViteSourceScanEntries, r as isUniAppXEnabled } from "./tailwindcss-xs704TRw.mjs";
5
5
  import "./utils-MVwpU07P.mjs";
6
6
  import { g as replaceWxml, y as createDebug } from "./wxml-DdGdeqaH.mjs";
7
- import { a as vitePluginName, c as collectRuntimeClassSet, d as refreshTailwindRuntimeState, f as normalizeFrameworkStylePlatform, l as createTailwindRuntimeReadyPromise, n as normalizeStyleHandlerMajorVersion, o as shouldSkipJsTransform, s as toCustomAttributesEntities, t as getCompilerContext } from "./context-BL8Gy71H.mjs";
8
- import { A as processCachedTask, D as createCssSourceTraceCacheSignature, E as annotateCssSourceTrace, O as createCssTokenSourceMap, S as scoreTailwindV4CssSourceFileMatch, _ as normalizeMiniProgramGeneratorCssSource, a as isSourceCandidateRequest, d as validateCandidatesByGenerator, g as mergeMarkedUserLayerComponentsCss, h as extractMarkedUserLayerComponentsCss, m as runWithConcurrency, r as createSourceCandidateCollector, s as createBundleRuntimeClassSetManager, t as createHmrTimingRecorder, v as normalizeMiniProgramImportShell, y as isPureLocalCssImportWrapper } from "./hmr-timing-C3ed5vCx.mjs";
9
- import { A as createBundlerGeneratedCssMarker, B as resolveViteFrameworkProfile, C as createBundleModuleGraphOptions, D as normalizeOutputPathKey, E as stripRequestQuery, F as resolvePluginDisabledState, I as createBuiltinViteStyleInjectorPlugins, M as parseBundlerGeneratedCssMarkerBlocks, N as stripBundlerGeneratedCssMarkers, P as resolvePackageDir, R as viteStyleInjectorDelegates, S as applyLinkedResults, T as isSourceStyleRequest, _ as isCSSRequest, a as createCandidateSignature, b as slash, c as getSnapshotHash, d as buildBundleSnapshot, g as formatPostcssSourceMap, h as cleanUrl, i as createScopedGeneratorSourceTraceMap, j as hasBundlerGeneratedCssMarker, k as toAbsoluteOutputPath, l as hasRuntimeAffectingSourceChanges, m as updateBundleBuildState, n as createScopedGeneratorCandidateSignature, o as createJsHashSalt, p as createBundleBuildState, r as createScopedGeneratorRuntime, s as createLinkedImpactSignature, t as createSourceCandidateScanSignature, u as summarizeStringDiff, v as isHTMLRequest, w as generateTailwindV4Css, x as createRuntimeAffectingSourceSignature, y as normalizePath } from "./source-candidate-scan-signature-D7RWjWsY.mjs";
7
+ import { a as vitePluginName, c as collectRuntimeClassSet, d as refreshTailwindRuntimeState, f as normalizeFrameworkStylePlatform, l as createTailwindRuntimeReadyPromise, n as normalizeStyleHandlerMajorVersion, o as shouldSkipJsTransform, s as toCustomAttributesEntities, t as getCompilerContext } from "./context-BgGWVAmN.mjs";
8
+ import { C as scoreTailwindV4CssSourceFileMatch, F as annotateCssSourceTrace, I as createCssSourceTraceCacheSignature, L as createCssTokenSourceMap, M as hasBundlerGeneratedCssMarker, N as parseBundlerGeneratedCssMarkerBlocks, O as isSourceStyleRequest, P as stripBundlerGeneratedCssMarkers, _ as mergeMarkedUserLayerComponentsCss, a as isSourceCandidateRequest, b as isPureLocalCssImportWrapper, c as createBundleRuntimeClassSetManager, f as validateCandidatesByGenerator, g as extractMarkedUserLayerComponentsCss, h as runWithConcurrency, j as createBundlerGeneratedCssMarker, k as stripRequestQuery, r as createSourceCandidateCollector, s as extractCandidatesFromSource, t as createHmrTimingRecorder, v as normalizeMiniProgramGeneratorCssSource, y as normalizeMiniProgramImportShell, z as processCachedTask } from "./hmr-timing-1aS6--U7.mjs";
9
+ import { A as createBuiltinViteStyleInjectorPlugins, C as createBundleModuleGraphOptions, D as toAbsoluteOutputPath, M as viteStyleInjectorDelegates, O as resolvePackageDir, P as resolveViteFrameworkProfile, S as applyLinkedResults, T as normalizeOutputPathKey, _ as isCSSRequest, a as createCandidateSignature, b as slash, c as getSnapshotHash, d as buildBundleSnapshot, g as formatPostcssSourceMap, h as cleanUrl, i as createScopedGeneratorSourceTraceMap, k as resolvePluginDisabledState, l as hasRuntimeAffectingSourceChanges, m as updateBundleBuildState, n as createScopedGeneratorCandidateSignature, o as createJsHashSalt, p as createBundleBuildState, r as createScopedGeneratorRuntime, s as createLinkedImpactSignature, t as createSourceCandidateScanSignature, u as summarizeStringDiff, v as isHTMLRequest, w as generateTailwindV4Css, x as createRuntimeAffectingSourceSignature, y as normalizePath } from "./source-candidate-scan-signature-Cf7259PR.mjs";
10
10
  import { t as logger$1 } from "./logger-BNzxZbZj.mjs";
11
11
  import fs, { existsSync, readFileSync, realpathSync } from "node:fs";
12
12
  import path from "node:path";
@@ -190,8 +190,28 @@ function createStyleValueFromApplySources(sources, utilityStyles) {
190
190
  }
191
191
  return Object.keys(result).length > 0 ? result : void 0;
192
192
  }
193
- function collectUniAppXHarmonyApplyStyleSourcesFromSource(source) {
194
- return (source.includes("<style") ? [...source.matchAll(SFC_STYLE_BLOCK_RE$2)].map((styleBlock) => styleBlock[1] ?? "") : [source]).map((styleSource) => styleSource.trim()).filter((styleSource) => styleSource.length > 0 && styleSource.includes("@apply"));
193
+ function resolveReferencePaths(styleSource, sourceId) {
194
+ if (!sourceId || !styleSource.includes("@reference")) return styleSource;
195
+ let root;
196
+ try {
197
+ root = postcss.parse(styleSource);
198
+ } catch {
199
+ return styleSource;
200
+ }
201
+ const cleanSourceId = sourceId.replace(/\?.*$/, "");
202
+ root.walkAtRules("reference", (rule) => {
203
+ const quote = rule.params[0];
204
+ if (quote !== "\"" && quote !== "'") return;
205
+ const closingQuoteIndex = rule.params.indexOf(quote, 1);
206
+ if (closingQuoteIndex <= 1) return;
207
+ const referencePath = rule.params.slice(1, closingQuoteIndex);
208
+ if (!referencePath.startsWith(".")) return;
209
+ rule.params = `${quote}${path.resolve(path.dirname(cleanSourceId), referencePath)}${quote}${rule.params.slice(closingQuoteIndex + 1)}`;
210
+ });
211
+ return root.toString();
212
+ }
213
+ function collectUniAppXHarmonyApplyStyleSourcesFromSource(source, sourceId) {
214
+ return (source.includes("<style") ? [...source.matchAll(SFC_STYLE_BLOCK_RE$2)].map((styleBlock) => styleBlock[1] ?? "") : [source]).map((styleSource) => resolveReferencePaths(styleSource.trim(), sourceId)).filter((styleSource) => styleSource.length > 0 && styleSource.includes("@apply"));
195
215
  }
196
216
  function collectUniAppXHarmonyApplyUtilitiesFromSources(sources) {
197
217
  const utilities = /* @__PURE__ */ new Set();
@@ -236,7 +256,18 @@ const STYLE_DECL_RE = /const\s+(_style_\d+)\s*=\s*\{/g;
236
256
  const EXPORT_SFC_RE = /_export_sfc\(_sfc_main\s*,\s*\[/;
237
257
  const UNI_APP_X_STYLE_PLACEHOLDER_VERSION = "uni-app-x-style-placeholder-v2";
238
258
  function createUniAppXHarmonyApplyGeneratorSource(applyStyleSources, _applyUtilities) {
239
- return applyStyleSources.join("\n");
259
+ return applyStyleSources.map((source) => {
260
+ let root;
261
+ try {
262
+ root = postcss.parse(source);
263
+ } catch {
264
+ return source;
265
+ }
266
+ root.walkAtRules("reference", (rule) => {
267
+ if (rule.params.match(/^(['"])(.+?)\1/)?.[2]?.startsWith(".")) rule.remove();
268
+ });
269
+ return root.toString();
270
+ }).join("\n");
240
271
  }
241
272
  function collectUniAppXHarmonyApplyUtilities(bundle) {
242
273
  const utilities = /* @__PURE__ */ new Set();
@@ -465,6 +496,127 @@ function createUniAppXBundleAssetSourceGetter(bundle) {
465
496
  };
466
497
  }
467
498
  //#endregion
499
+ //#region src/bundlers/vite/generate-bundle/transform-filter.ts
500
+ function toArray(value) {
501
+ return Array.isArray(value) ? value : value === void 0 ? [] : [value];
502
+ }
503
+ function normalizeSourceId(id) {
504
+ const file = cleanUrl(id);
505
+ return path.isAbsolute(file) ? path.resolve(file) : void 0;
506
+ }
507
+ function collectChunkModuleIds$2(chunk) {
508
+ const ids = /* @__PURE__ */ new Set();
509
+ for (const id of chunk.moduleIds ?? []) {
510
+ const normalized = normalizeSourceId(id);
511
+ if (normalized) ids.add(normalized);
512
+ }
513
+ for (const id of Object.keys(chunk.modules ?? {})) {
514
+ const normalized = normalizeSourceId(id);
515
+ if (normalized) ids.add(normalized);
516
+ }
517
+ return ids;
518
+ }
519
+ function collectAssetSourceIds(asset, fallbackFile, rootDir) {
520
+ const ids = /* @__PURE__ */ new Set();
521
+ const sourceCandidates = [asset.originalFileName, ...asset.originalFileNames ?? []].filter((candidate) => typeof candidate === "string" && candidate.length > 0);
522
+ const candidates = sourceCandidates.length > 0 ? sourceCandidates : [fallbackFile];
523
+ for (const candidate of candidates) {
524
+ if (typeof candidate !== "string" || candidate.length === 0) continue;
525
+ const cleanCandidate = cleanUrl(candidate);
526
+ const resolved = path.isAbsolute(cleanCandidate) ? path.resolve(cleanCandidate) : path.resolve(rootDir, cleanCandidate);
527
+ ids.add(resolved);
528
+ }
529
+ return ids;
530
+ }
531
+ function isStringRuleMatched(rule, id, rootDir) {
532
+ const normalizedId = slash(id);
533
+ const normalizedRule = slash(rule);
534
+ if (path.isAbsolute(rule)) return micromatch.isMatch(normalizedId, normalizedRule);
535
+ const relative = slash(path.relative(rootDir, id));
536
+ return relative.length > 0 && !relative.startsWith("../") && !path.isAbsolute(relative) && micromatch.isMatch(relative, normalizedRule);
537
+ }
538
+ function isRuleMatched(rule, id, rootDir) {
539
+ if (typeof rule === "string") return isStringRuleMatched(rule, id, rootDir);
540
+ if (rule instanceof RegExp) {
541
+ rule.lastIndex = 0;
542
+ return rule.test(slash(id));
543
+ }
544
+ return rule(id) === true;
545
+ }
546
+ function createTransformMatcher(rules, rootDir) {
547
+ const normalizedRules = toArray(rules);
548
+ if (normalizedRules.length === 0) return;
549
+ return (id) => normalizedRules.some((rule) => isRuleMatched(rule, id, rootDir));
550
+ }
551
+ function shouldSkipSourceIds(sourceIds, filter) {
552
+ if (sourceIds.size === 0) return false;
553
+ if (filter.exclude) {
554
+ let excluded = true;
555
+ for (const id of sourceIds) if (!filter.exclude(id)) {
556
+ excluded = false;
557
+ break;
558
+ }
559
+ if (excluded) return true;
560
+ }
561
+ if (filter.include) {
562
+ for (const id of sourceIds) if (filter.include(id)) return false;
563
+ return true;
564
+ }
565
+ return false;
566
+ }
567
+ function createTransformFilter(options, rootDir) {
568
+ const include = createTransformMatcher(options?.include, rootDir);
569
+ const exclude = createTransformMatcher(options?.exclude, rootDir);
570
+ if (!include && !exclude) return;
571
+ return {
572
+ include,
573
+ exclude
574
+ };
575
+ }
576
+ function shouldSkipViteJsChunkTransform(chunk, filter) {
577
+ if (!filter) return false;
578
+ return shouldSkipSourceIds(collectChunkModuleIds$2(chunk), filter);
579
+ }
580
+ function shouldSkipViteAssetTransform(asset, file, rootDir, filter) {
581
+ if (!filter) return false;
582
+ return shouldSkipSourceIds(collectAssetSourceIds(asset, file, rootDir), filter);
583
+ }
584
+ function createRuleSignature(rules) {
585
+ return toArray(rules).map((rule) => {
586
+ if (typeof rule === "string") return `s:${rule}`;
587
+ if (rule instanceof RegExp) return `r:${rule.source}/${rule.flags}`;
588
+ return "f";
589
+ }).join("|") || "none";
590
+ }
591
+ function createTransformFilterSignature(options) {
592
+ return [`include:${createRuleSignature(options?.include)}`, `exclude:${createRuleSignature(options?.exclude)}`].join(";");
593
+ }
594
+ //#endregion
595
+ //#region src/bundlers/vite/generate-bundle/bundle-markup-candidates.ts
596
+ async function collectBundleMarkupCandidates(options) {
597
+ const { extractSourceCandidates, previousCandidatesByFile, preserveMissingFiles, resolveSourceCandidateFile, rootDir, snapshot, transformFilter } = options;
598
+ const candidatesByFile = preserveMissingFiles ? new Map([...previousCandidatesByFile ?? []].map(([file, candidates]) => [file, new Set(candidates)])) : /* @__PURE__ */ new Map();
599
+ await Promise.all(snapshot.entries.map(async (entry) => {
600
+ if (!extractSourceCandidates || entry.type !== "html" || entry.output.type !== "asset" || shouldSkipViteAssetTransform(entry.output, entry.file, rootDir, transformFilter)) return;
601
+ const sourceFile = resolveSourceCandidateFile(entry.file) ?? path.resolve(rootDir, entry.file);
602
+ candidatesByFile.set(sourceFile, await extractSourceCandidates(sourceFile, entry.source));
603
+ }));
604
+ const valuesForEntries = (entries, filterOptions = {}) => {
605
+ const values = /* @__PURE__ */ new Set();
606
+ for (const [file, candidates] of candidatesByFile) {
607
+ if (entries !== void 0 && !isFileMatchedByTailwindSourceEntries(file, entries)) continue;
608
+ if (filterOptions.excludeEntries?.length && isFileMatchedByTailwindSourceEntries(file, filterOptions.excludeEntries)) continue;
609
+ for (const candidate of candidates) values.add(candidate);
610
+ }
611
+ return values;
612
+ };
613
+ return {
614
+ candidatesByFile,
615
+ values: valuesForEntries(void 0),
616
+ valuesForEntries
617
+ };
618
+ }
619
+ //#endregion
468
620
  //#region src/bundlers/vite/generate-bundle/configured-css-sources.ts
469
621
  function collectConfiguredTailwindV4CssSources(opts) {
470
622
  const runtimeCssSources = opts.tailwindcssRuntimeOptions?.tailwindcss?.v4?.cssSources ?? [];
@@ -548,7 +700,8 @@ function registerGeneratorDependencies$1(ctx, dependencies) {
548
700
  //#region src/bundlers/vite/generate-bundle/css-assets.ts
549
701
  function createCssAssetEmitter(context, bundle) {
550
702
  return (fileName, source) => {
551
- const existing = bundle?.[fileName];
703
+ const fileNameKey = normalizeOutputPathKey(fileName);
704
+ const existing = bundle?.[fileName] ?? Object.entries(bundle ?? {}).find(([bundleFile, output]) => output != null && typeof output === "object" && "type" in output && output.type === "asset" && normalizeOutputPathKey("fileName" in output && typeof output.fileName === "string" ? output.fileName : bundleFile) === fileNameKey)?.[1];
552
705
  if (existing && typeof existing === "object" && "type" in existing && existing.type === "asset") {
553
706
  existing.source = source;
554
707
  return existing;
@@ -645,8 +798,9 @@ function resolveMiniProgramStyleOutputExtension(options = {}) {
645
798
  return resolveStyleOutputExtensionFromFiles(options.files, options.cssMatcher, options.stem) ?? resolveStyleOutputExtensionFromFiles(options.files, options.cssMatcher) ?? resolveStyleOutputExtensionFromMatcher(options.cssMatcher, options.stem) ?? normalizeStyleOutputExtension(options.fallback) ?? FALLBACK_STYLE_OUTPUT_EXTENSION;
646
799
  }
647
800
  function resolveReplayCssOutputFile(rootDir, file) {
648
- const normalizedFile = normalizeOutputPathKey(path.isAbsolute(file) ? path.relative(resolveCssOutputRealPath(rootDir), resolveCssOutputRealPath(file)) : file);
649
- if (normalizedFile.length === 0 || normalizedFile === "." || normalizedFile === ".." || normalizedFile.startsWith("../")) return normalizeOutputPathKey(path.basename(file));
801
+ const cleanFile = file.replace(/[?#].*$/, "");
802
+ const normalizedFile = normalizeOutputPathKey(path.isAbsolute(cleanFile) ? path.relative(resolveCssOutputRealPath(rootDir), resolveCssOutputRealPath(cleanFile)) : cleanFile);
803
+ if (normalizedFile.length === 0 || normalizedFile === "." || normalizedFile === ".." || normalizedFile.startsWith("../")) return normalizeOutputPathKey(path.basename(cleanFile));
650
804
  return normalizedFile;
651
805
  }
652
806
  function normalizeViteSourceRoot(rootDir, sourceRoot) {
@@ -662,9 +816,10 @@ function resolveReplayCssOutputFileFromSourceRoot(rootDir, file, sourceRoot) {
662
816
  return outputFile;
663
817
  }
664
818
  function resolveViteCssOutputFile(file, opts, isWebGeneratorTarget, preserveCssExtension = false, styleOutputExtension, styleOutputFiles) {
665
- if (isWebGeneratorTarget || preserveCssExtension || opts.cssMatcher(file) || !CSS_SOURCE_OUTPUT_EXT_RE.test(file) || !isCSSRequest(file)) return file;
666
- const stem = file.replace(/[?#].*$/, "").replace(CSS_SOURCE_OUTPUT_EXT_RE, "");
667
- return file.replace(CSS_SOURCE_OUTPUT_EXT_RE, resolveMiniProgramStyleOutputExtension({
819
+ const cleanFile = file.replace(/[?#].*$/, "");
820
+ if (isWebGeneratorTarget || preserveCssExtension || opts.cssMatcher(cleanFile) || !CSS_SOURCE_OUTPUT_EXT_RE.test(cleanFile) || !isCSSRequest(file)) return cleanFile;
821
+ const stem = cleanFile.replace(CSS_SOURCE_OUTPUT_EXT_RE, "");
822
+ return cleanFile.replace(CSS_SOURCE_OUTPUT_EXT_RE, resolveMiniProgramStyleOutputExtension({
668
823
  cssMatcher: opts.cssMatcher,
669
824
  fallback: styleOutputExtension,
670
825
  files: styleOutputFiles,
@@ -672,20 +827,40 @@ function resolveViteCssOutputFile(file, opts, isWebGeneratorTarget, preserveCssE
672
827
  }));
673
828
  }
674
829
  function resolveViteCssPipelineOutputFile(file, opts, rootDir, isWebGeneratorTarget = false, preserveCssExtension = false, sourceRoot, styleOutputExtension, styleOutputFiles) {
675
- const normalizedFile = resolveReplayCssOutputFileFromSourceRoot(rootDir, file, sourceRoot);
676
- const cleanFile = normalizedFile.replace(/[?#].*$/, "");
830
+ const sourceStyleRequest = isCSSRequest(file);
831
+ const cleanFile = resolveReplayCssOutputFileFromSourceRoot(rootDir, file, sourceRoot).replace(/[?#].*$/, "");
832
+ const sourceExtension = path.extname(cleanFile);
833
+ if (sourceStyleRequest && !isWebGeneratorTarget && !preserveCssExtension && sourceExtension.length > 0 && !CSS_SOURCE_OUTPUT_EXT_RE.test(cleanFile)) {
834
+ const stem = cleanFile.slice(0, -sourceExtension.length);
835
+ return `${stem}${resolveMiniProgramStyleOutputExtension({
836
+ cssMatcher: opts.cssMatcher,
837
+ fallback: styleOutputExtension,
838
+ files: styleOutputFiles,
839
+ stem
840
+ })}`;
841
+ }
677
842
  const stem = cleanFile.replace(CSS_SOURCE_OUTPUT_EXT_RE, "");
678
843
  const matchedStyleExtension = !isWebGeneratorTarget && !preserveCssExtension ? resolveStyleOutputExtensionFromFiles(styleOutputFiles, opts.cssMatcher, stem) : void 0;
679
- if (matchedStyleExtension && CSS_SOURCE_OUTPUT_EXT_RE.test(cleanFile) && isCSSRequest(normalizedFile)) return normalizedFile.replace(CSS_SOURCE_OUTPUT_EXT_RE, matchedStyleExtension);
680
- if (isWebGeneratorTarget || preserveCssExtension || opts.cssMatcher(normalizedFile) || !CSS_SOURCE_OUTPUT_EXT_RE.test(normalizedFile) || !isCSSRequest(normalizedFile)) return normalizedFile;
844
+ if (matchedStyleExtension && CSS_SOURCE_OUTPUT_EXT_RE.test(cleanFile) && sourceStyleRequest) return cleanFile.replace(CSS_SOURCE_OUTPUT_EXT_RE, matchedStyleExtension);
845
+ if (isWebGeneratorTarget || preserveCssExtension || opts.cssMatcher(cleanFile) || !CSS_SOURCE_OUTPUT_EXT_RE.test(cleanFile) || !sourceStyleRequest) return cleanFile;
681
846
  const fallbackExtension = normalizeStyleOutputExtension(styleOutputExtension);
682
- if (!fallbackExtension && !SOURCE_STYLE_OUTPUT_EXT_RE.test(normalizedFile)) return normalizedFile;
683
- return normalizedFile.replace(CSS_SOURCE_OUTPUT_EXT_RE, fallbackExtension ?? FALLBACK_STYLE_OUTPUT_EXTENSION);
847
+ if (!fallbackExtension && !SOURCE_STYLE_OUTPUT_EXT_RE.test(cleanFile)) return cleanFile;
848
+ return cleanFile.replace(CSS_SOURCE_OUTPUT_EXT_RE, fallbackExtension ?? FALLBACK_STYLE_OUTPUT_EXTENSION);
684
849
  }
685
850
  function resolveViteCssPipelineOutputFileFromSourceFile(sourceFile, opts, rootDir, isWebGeneratorTarget = false, preserveCssExtension = false, sourceRoot, styleOutputExtension, styleOutputFiles) {
686
- const normalizedFile = resolveReplayCssOutputFileFromSourceRoot(rootDir, sourceFile, sourceRoot);
687
- const cleanFile = normalizedFile.replace(/[?#].*$/, "");
688
- if (isWebGeneratorTarget || preserveCssExtension || !CSS_SOURCE_OUTPUT_EXT_RE.test(cleanFile) || !isCSSRequest(normalizedFile)) return normalizedFile;
851
+ const sourceStyleRequest = isCSSRequest(sourceFile);
852
+ const cleanFile = resolveReplayCssOutputFileFromSourceRoot(rootDir, sourceFile, sourceRoot).replace(/[?#].*$/, "");
853
+ const sourceExtension = path.extname(cleanFile);
854
+ if (sourceStyleRequest && !isWebGeneratorTarget && !preserveCssExtension && sourceExtension.length > 0 && !CSS_SOURCE_OUTPUT_EXT_RE.test(cleanFile)) {
855
+ const stem = cleanFile.slice(0, -sourceExtension.length);
856
+ return resolveStyleOutputFileFromFiles(styleOutputFiles, opts.cssMatcher, stem) ?? `${stem}${resolveMiniProgramStyleOutputExtension({
857
+ cssMatcher: opts.cssMatcher,
858
+ fallback: styleOutputExtension,
859
+ files: styleOutputFiles,
860
+ stem
861
+ })}`;
862
+ }
863
+ if (isWebGeneratorTarget || preserveCssExtension || !CSS_SOURCE_OUTPUT_EXT_RE.test(cleanFile) || !sourceStyleRequest) return cleanFile;
689
864
  const stem = cleanFile.replace(CSS_SOURCE_OUTPUT_EXT_RE, "");
690
865
  const matchedStyleFile = resolveStyleOutputFileFromFiles(styleOutputFiles, opts.cssMatcher, stem);
691
866
  if (matchedStyleFile) return matchedStyleFile;
@@ -695,7 +870,7 @@ function resolveViteCssPipelineOutputFileFromSourceFile(sourceFile, opts, rootDi
695
870
  files: styleOutputFiles,
696
871
  stem
697
872
  }) ?? normalizeStyleOutputExtension(styleOutputExtension);
698
- return normalizedFile.replace(CSS_SOURCE_OUTPUT_EXT_RE, styleExtension);
873
+ return cleanFile.replace(CSS_SOURCE_OUTPUT_EXT_RE, styleExtension);
699
874
  }
700
875
  function canProcessViteSourceStyleAsCss(source, file) {
701
876
  if (SOURCE_STYLE_NON_CSS_SYNTAX_RE.test(source)) return false;
@@ -847,7 +1022,8 @@ function createCssHandlerOptionsCache(options) {
847
1022
  const appType = options.getAppType();
848
1023
  const isMainChunk = options.mainCssChunkMatcher(file, appType);
849
1024
  const outputRoot = options.getOutputRoot?.();
850
- const from = path.isAbsolute(file) ? file : outputRoot ? path.resolve(outputRoot, file) : file;
1025
+ const sourceFile = stripRequestQuery(file);
1026
+ const from = path.isAbsolute(sourceFile) ? sourceFile : outputRoot ? path.resolve(outputRoot, sourceFile) : sourceFile;
851
1027
  const extraOptions = options.getExtraOptions?.(file) ?? {};
852
1028
  const dynamicCssOptions = options.getDynamicCssOptions?.() ?? {};
853
1029
  const cacheKey = `${majorVersion ?? "unknown"}:${appType ?? "unknown"}:${isMainChunk ? "1" : "0"}:${outputRoot ?? ""}:${file}:${JSON.stringify(extraOptions)}:${JSON.stringify(dynamicCssOptions)}`;
@@ -859,7 +1035,10 @@ function createCssHandlerOptionsCache(options) {
859
1035
  ...dynamicCssOptions,
860
1036
  postcssOptions: { options: { from } },
861
1037
  majorVersion: normalizeStyleHandlerMajorVersion(majorVersion),
862
- sourceOptions: { outputRoot }
1038
+ sourceOptions: {
1039
+ outputRoot,
1040
+ ...sourceFile === file ? {} : { requestFile: file }
1041
+ }
863
1042
  };
864
1043
  cssHandlerOptionsCache.set(cacheKey, created);
865
1044
  return created;
@@ -962,6 +1141,7 @@ function shouldSkipRawSourceStyleAsset(outputFile, file, rawSource, assetSourceF
962
1141
  const source = rawSource.trim();
963
1142
  if (source.length === 0) return false;
964
1143
  if (canProcessViteSourceStyleAsCss(source, file)) return false;
1144
+ if (SOURCE_STYLE_OUTPUT_EXT_RE.test(assetSourceFile.replace(/[?#].*$/, ""))) return true;
965
1145
  const isKnownStyleSource = isSourceStyleRequest(assetSourceFile) || cssMatcher?.(assetSourceFile) === true;
966
1146
  return outputFile !== file || !isKnownStyleSource;
967
1147
  }
@@ -1530,6 +1710,10 @@ const SFC_STYLE_SOURCE_EXTENSIONS = [
1530
1710
  const SFC_STYLE_BLOCK_RE$1 = /<style\b([^>]*)>([\s\S]*?)<\/style>/gi;
1531
1711
  const SFC_SCOPED_STYLE_ATTR_RE = /(?:^|\s)scoped(?:\s|=|$)/i;
1532
1712
  const SFC_LANG_STYLE_ATTR_RE = /(?:^|\s)lang(?:=(?:"([^"]+)"|'([^']+)'|([^\s"'=<>`]+)))?/i;
1713
+ function isSfcStyleSourceFile(file) {
1714
+ const normalizedFile = file.replace(/[?#].*$/, "");
1715
+ return SFC_STYLE_SOURCE_EXTENSIONS.some((extension) => normalizedFile.endsWith(extension));
1716
+ }
1533
1717
  function extractSfcStyleBlocks(source) {
1534
1718
  const styleSources = [];
1535
1719
  SFC_STYLE_BLOCK_RE$1.lastIndex = 0;
@@ -1575,7 +1759,7 @@ function createSfcStyleRequest(sourceFile, styleBlock) {
1575
1759
  if (lang) params.set("lang", lang);
1576
1760
  return `${sourceFile}?${params.toString()}`;
1577
1761
  }
1578
- function resolveSfcStyleRequestFromKnownSource(sourceFile, sfcSource, styleSource) {
1762
+ function resolveSfcStyleRequestFromKnownSource(sourceFile, sfcSource, styleSource, currentRequest) {
1579
1763
  if (!sfcSource) return sourceFile;
1580
1764
  const styleBlocks = extractSfcStyleBlocks(sfcSource);
1581
1765
  if (styleBlocks.length === 0) return sourceFile;
@@ -1584,7 +1768,8 @@ function resolveSfcStyleRequestFromKnownSource(sourceFile, sfcSource, styleSourc
1584
1768
  const normalizedBlockSource = normalizeSfcStyleSourceForCompare(styleBlock.source);
1585
1769
  return normalizedBlockSource === normalizedStyleSource || normalizedBlockSource.includes(normalizedStyleSource) || normalizedStyleSource.includes(normalizedBlockSource);
1586
1770
  });
1587
- const styleBlock = matchedBlocks.length === 1 ? matchedBlocks[0] : styleBlocks.length === 1 ? styleBlocks[0] : void 0;
1771
+ const requestIndex = currentRequest ? Number.parseInt(new URLSearchParams(currentRequest.split("?", 2)[1] ?? "").get("index") ?? "", 10) : NaN;
1772
+ const styleBlock = (Number.isInteger(requestIndex) ? styleBlocks.find((styleBlock) => styleBlock.index === requestIndex) : void 0) ?? (matchedBlocks.length === 1 ? matchedBlocks[0] : styleBlocks.length === 1 ? styleBlocks[0] : void 0);
1588
1773
  return styleBlock ? createSfcStyleRequest(sourceFile, styleBlock) : sourceFile;
1589
1774
  }
1590
1775
  function hasTailwindGenerationSource(source, options = {}) {
@@ -1622,7 +1807,7 @@ async function resolveSfcStyleSourceFromOutputFile(outputFile, snapshot, outputR
1622
1807
  function normalizeSfcSourceFileForCompare(file) {
1623
1808
  return normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
1624
1809
  }
1625
- function collectChunkModuleIds$2(output) {
1810
+ function collectChunkModuleIds$1(output) {
1626
1811
  const moduleIds = Array.isArray(output.moduleIds) ? output.moduleIds : [];
1627
1812
  return [
1628
1813
  output.facadeModuleId,
@@ -1646,7 +1831,7 @@ function resolveSiblingJsChunkFile(outputFile, cssMatcher) {
1646
1831
  }
1647
1832
  function normalizeSfcModuleId(id) {
1648
1833
  const file = id.replace(/[?#].*$/, "");
1649
- if (!SFC_STYLE_SOURCE_EXTENSIONS.some((extension) => file.endsWith(extension))) return;
1834
+ if (!isSfcStyleSourceFile(file)) return;
1650
1835
  if (!path.isAbsolute(file)) return;
1651
1836
  return path.resolve(file);
1652
1837
  }
@@ -1662,7 +1847,7 @@ function resolveSfcStyleFileFromSiblingChunk(outputFile, snapshot, outputRoot, s
1662
1847
  debug("sfc style sibling chunk skipped: missing chunk for %s -> %s", outputFile, siblingJsFile);
1663
1848
  return;
1664
1849
  }
1665
- const sourceFiles = collectChunkModuleIds$2(siblingChunk.output).map(normalizeSfcModuleId).filter((file, index, files) => Boolean(file) && files.indexOf(file) === index);
1850
+ const sourceFiles = collectChunkModuleIds$1(siblingChunk.output).map(normalizeSfcModuleId).filter((file, index, files) => Boolean(file) && files.indexOf(file) === index);
1666
1851
  if (sourceFiles.length === 0) {
1667
1852
  debug("sfc style sibling chunk skipped: no sfc modules for %s -> %s", outputFile, siblingJsFile);
1668
1853
  return;
@@ -1693,7 +1878,7 @@ function resolveSourceStyleFileFromSiblingChunk(outputFile, snapshot, outputRoot
1693
1878
  debug("source style sibling chunk skipped: missing chunk for %s -> %s", outputFile, siblingJsFile);
1694
1879
  return;
1695
1880
  }
1696
- const sourceFiles = collectChunkModuleIds$2(siblingChunk.output).map(normalizeSourceStyleModuleId).filter((file, index, files) => Boolean(file) && files.indexOf(file) === index);
1881
+ const sourceFiles = collectChunkModuleIds$1(siblingChunk.output).map(normalizeSourceStyleModuleId).filter((file, index, files) => Boolean(file) && files.indexOf(file) === index);
1697
1882
  if (sourceFiles.length === 0) {
1698
1883
  debug("source style sibling chunk skipped: no source style modules for %s -> %s", outputFile, siblingJsFile);
1699
1884
  return;
@@ -1812,7 +1997,7 @@ function collectMiniProgramSubpackageSourceEntries(snapshot, subpackageRoots, so
1812
1997
  if (entry.output.type !== "chunk" || !isSubpackageOutputFile(entry.file, subpackageRoots)) continue;
1813
1998
  const matchedSubpackageRoot = [...subpackageRoots].find((root) => isSubpackageOutputFile(entry.file, /* @__PURE__ */ new Set([root])));
1814
1999
  if (!matchedSubpackageRoot) continue;
1815
- for (const moduleId of collectChunkModuleIds$2(entry.output)) {
2000
+ for (const moduleId of collectChunkModuleIds$1(entry.output)) {
1816
2001
  if (!path.isAbsolute(moduleId.replace(/[?#].*$/, ""))) continue;
1817
2002
  const sourceRoot = resolveSubpackageSourceRootFromModuleId(moduleId, matchedSubpackageRoot);
1818
2003
  if (sourceRoot) sourceRoots.add(sourceRoot);
@@ -3343,11 +3528,12 @@ function collectUnescapedDynamicCandidates(source, allowedCandidates) {
3343
3528
  //#region src/bundlers/vite/generate-bundle/html-processing.ts
3344
3529
  function processHtmlBundleEntry(options) {
3345
3530
  const { cache, context, debug, dynamicRetryCandidates, file, metrics, onUpdate, originalEntrySource, originalSource, rememberProcessCacheKey, resolveCurrentSourceCandidateSource, tasks, templateHandler, timeTask, transformRuntime, transformRuntimeSignature } = options;
3346
- const rawSource = resolveCurrentSourceCandidateSource(file) ?? originalEntrySource;
3347
- const currentRawDynamicCandidates = collectUnescapedDynamicCandidates(rawSource);
3348
- const templateRuntime = currentRawDynamicCandidates.length > 0 ? /* @__PURE__ */ new Set([...transformRuntime, ...currentRawDynamicCandidates]) : transformRuntime;
3531
+ const currentBundleSource = originalEntrySource;
3532
+ const candidateSource = resolveCurrentSourceCandidateSource(file) ?? currentBundleSource;
3533
+ const currentRawDynamicCandidates = /* @__PURE__ */ new Set([...collectUnescapedDynamicCandidates(candidateSource), ...collectUnescapedDynamicCandidates(currentBundleSource)]);
3534
+ const templateRuntime = currentRawDynamicCandidates.size > 0 ? /* @__PURE__ */ new Set([...transformRuntime, ...currentRawDynamicCandidates]) : transformRuntime;
3349
3535
  const templateRuntimeSignature = templateRuntime === transformRuntime ? transformRuntimeSignature : createCandidateSignature(templateRuntime);
3350
- const htmlProcessHash = `${cache.computeHash(rawSource)}:${cache.computeHash(createRuntimeAffectingSourceSignature(rawSource, "html"))}:${templateRuntimeSignature}`;
3536
+ const htmlProcessHash = `${cache.computeHash(currentBundleSource)}:${cache.computeHash(createRuntimeAffectingSourceSignature(currentBundleSource, "html"))}:${templateRuntimeSignature}`;
3351
3537
  const cacheKey = `${file}:html:${htmlProcessHash}`;
3352
3538
  const hashKey = cacheKey;
3353
3539
  rememberProcessCacheKey(cacheKey, hashKey);
@@ -3365,7 +3551,7 @@ function processHtmlBundleEntry(options) {
3365
3551
  },
3366
3552
  async transform() {
3367
3553
  const start = performance.now();
3368
- let transformed = await templateHandler(rawSource, { runtimeSet: templateRuntime });
3554
+ let transformed = await templateHandler(currentBundleSource, { runtimeSet: templateRuntime });
3369
3555
  let unresolvedDynamicCandidates = collectUnescapedDynamicCandidates(transformed);
3370
3556
  let retryRuntimeSet;
3371
3557
  if (unresolvedDynamicCandidates.length > 0) {
@@ -3376,13 +3562,13 @@ function processHtmlBundleEntry(options) {
3376
3562
  }
3377
3563
  if (retryRuntimeSet && unresolvedDynamicCandidates.length > 0) {
3378
3564
  logger.warn("检测到已提取 WXML 动态类名未完成转译,已回退到完整 runtimeSet 重试: %s -> %O", file, unresolvedDynamicCandidates);
3379
- transformed = await templateHandler(rawSource, { runtimeSet: retryRuntimeSet });
3565
+ transformed = await templateHandler(currentBundleSource, { runtimeSet: retryRuntimeSet });
3380
3566
  unresolvedDynamicCandidates = collectUnescapedDynamicCandidates(transformed, retryRuntimeSet);
3381
3567
  if (unresolvedDynamicCandidates.length > 0) logger.warn("已提取 WXML 动态类名在完整 runtimeSet 重试后仍未完成转译: %s -> %O", file, unresolvedDynamicCandidates);
3382
3568
  }
3383
3569
  metrics.html.elapsed += measureElapsed(start);
3384
3570
  metrics.html.transformed++;
3385
- onUpdate(file, rawSource, transformed);
3571
+ onUpdate(file, currentBundleSource, transformed);
3386
3572
  debug("html handle: %s", file);
3387
3573
  return { result: transformed };
3388
3574
  }
@@ -3488,7 +3674,7 @@ function resolveUniAppXStyleIsolationEnabled(root) {
3488
3674
  //#region src/uni-app-x/vite.ts
3489
3675
  let transformUVuePromise;
3490
3676
  function loadTransformUVue() {
3491
- transformUVuePromise ?? (transformUVuePromise = import("./transform-D5JUgMpE.mjs").then((mod) => mod.transformUVue));
3677
+ transformUVuePromise ?? (transformUVuePromise = import("./transform-B_KM9sLX.mjs").then((mod) => mod.transformUVue));
3492
3678
  return transformUVuePromise;
3493
3679
  }
3494
3680
  const preprocessorLangs = /* @__PURE__ */ new Set([
@@ -3529,8 +3715,8 @@ function createUniAppXPlugins(options) {
3529
3715
  let componentLocalStyleEnabled;
3530
3716
  const harmonyApplyStyleSources = /* @__PURE__ */ new Set();
3531
3717
  const harmonyApplyUtilities = /* @__PURE__ */ new Set();
3532
- function rememberHarmonyApplySource(code) {
3533
- const styleSources = collectUniAppXHarmonyApplyStyleSourcesFromSource(code);
3718
+ function rememberHarmonyApplySource(code, id) {
3719
+ const styleSources = collectUniAppXHarmonyApplyStyleSourcesFromSource(code, id);
3534
3720
  if (styleSources.length === 0) return;
3535
3721
  for (const styleSource of styleSources) {
3536
3722
  harmonyApplyStyleSources.add(styleSource);
@@ -3563,7 +3749,7 @@ function createUniAppXPlugins(options) {
3563
3749
  if (isCSSRequest(id) || parsed.vue && parsed.type === "style") {
3564
3750
  if (isCssModuleExport(code)) return;
3565
3751
  const shouldGenerateCss = hasTailwindSourceDirectives(code, { importFallback: true }) || hasTailwindApplyDirective(code);
3566
- rememberHarmonyApplySource(code);
3752
+ rememberHarmonyApplySource(code, id);
3567
3753
  const generatedCss = shouldGenerateCss ? await generateCss?.(id, code, hookContext) : void 0;
3568
3754
  const styleCode = typeof generatedCss === "string" && generatedCss.trim().length > 0 ? generatedCss : code;
3569
3755
  const cacheKey = `${mainCssChunkMatcher(id, appType) ? "1" : "0"}:${id}`;
@@ -3623,7 +3809,7 @@ function createUniAppXPlugins(options) {
3623
3809
  async transform(code, id) {
3624
3810
  if (!isEnabled()) return;
3625
3811
  if (!UVUE_NVUE_QUERY_RE.test(id)) return;
3626
- rememberHarmonyApplySource(code);
3812
+ rememberHarmonyApplySource(code, id);
3627
3813
  const resolvedConfig = getResolvedConfig();
3628
3814
  const isServeCommand = resolvedConfig?.command === "serve";
3629
3815
  const isWatchBuild = resolvedConfig?.command === "build" && !!resolvedConfig.build?.watch;
@@ -3632,13 +3818,19 @@ function createUniAppXPlugins(options) {
3632
3818
  const transformUVue = await loadTransformUVue();
3633
3819
  const enableComponentLocalStyle = shouldEnableComponentLocalStyle();
3634
3820
  const enablePageLocalStyle = shouldEnableHarmonyPageLocalStyle();
3635
- if (customAttributesEntities.length > 0 || disabledDefaultTemplateHandler || enableComponentLocalStyle || enablePageLocalStyle) return transformUVue(code, id, jsHandler, currentRuntimeSet, omitUndefined({
3636
- ...customAttributesEntities.length > 0 ? { customAttributesEntities } : {},
3637
- ...disabledDefaultTemplateHandler ? { disabledDefaultTemplateHandler } : {},
3638
- ...enableComponentLocalStyle ? { enableComponentLocalStyle } : {},
3639
- ...enablePageLocalStyle ? { enablePageLocalStyle } : {}
3640
- }));
3641
- return transformUVue(code, id, jsHandler, currentRuntimeSet);
3821
+ if (customAttributesEntities.length > 0 || disabledDefaultTemplateHandler || enableComponentLocalStyle || enablePageLocalStyle) {
3822
+ const result = transformUVue(code, id, jsHandler, currentRuntimeSet, omitUndefined({
3823
+ ...customAttributesEntities.length > 0 ? { customAttributesEntities } : {},
3824
+ ...disabledDefaultTemplateHandler ? { disabledDefaultTemplateHandler } : {},
3825
+ ...enableComponentLocalStyle ? { enableComponentLocalStyle } : {},
3826
+ ...enablePageLocalStyle ? { enablePageLocalStyle } : {}
3827
+ }));
3828
+ if (result?.code) rememberHarmonyApplySource(result.code, id);
3829
+ return result;
3830
+ }
3831
+ const result = transformUVue(code, id, jsHandler, currentRuntimeSet);
3832
+ if (result?.code) rememberHarmonyApplySource(result.code, id);
3833
+ return result;
3642
3834
  },
3643
3835
  async handleHotUpdate(ctx) {
3644
3836
  if (!isEnabled()) return;
@@ -3668,7 +3860,7 @@ function createUniAppXPlugins(options) {
3668
3860
  const getAssetSource = createUniAppXBundleAssetSourceGetter(bundle);
3669
3861
  if (isHarmonyTarget) {
3670
3862
  const cssSources = [];
3671
- const applyStyleSources = [...harmonyApplyStyleSources, ...collectUniAppXHarmonyApplyStyleSources(bundle)];
3863
+ const applyStyleSources = harmonyApplyStyleSources.size > 0 ? [...harmonyApplyStyleSources] : collectUniAppXHarmonyApplyStyleSources(bundle);
3672
3864
  const applyUtilities = /* @__PURE__ */ new Set([...harmonyApplyUtilities, ...collectUniAppXHarmonyApplyUtilities(bundle)]);
3673
3865
  if (applyStyleSources.length > 0 && applyUtilities.size > 0) {
3674
3866
  const harmonyApplyCssFile = path.resolve(getResolvedConfig()?.root ?? process$1.cwd(), "uni-app-x-harmony-apply.css");
@@ -3946,17 +4138,25 @@ function collectRememberedCssReplayGroups(sources, opts, rootDir, isWebGenerator
3946
4138
  }
3947
4139
  //#endregion
3948
4140
  //#region src/bundlers/vite/generate-bundle/remembered-css-replay.ts
4141
+ function shouldSkipRawRememberedCssSource(rawSource, sourceFile) {
4142
+ const cleanSourceFile = sourceFile.replace(/[?#].*$/, "");
4143
+ return SOURCE_STYLE_OUTPUT_EXT_RE.test(cleanSourceFile) && !canProcessViteSourceStyleAsCss(rawSource, sourceFile);
4144
+ }
3949
4145
  async function processRememberedCssReplay(options) {
3950
4146
  const { addWatchFile, activeViteCssCacheFiles, bundleFiles, cache, changedCssFiles = /* @__PURE__ */ new Set(), createScopedGeneratorRuntime, createScopedSourceCandidateGetter, createScopedSourceCandidateSourceGetter, cssTaskFactories, cssPipelineContext, cssPipelineStrategy, debug, defaultStyleOutputExtension, emitOrReplayCssAsset, generatorRuntime, generatorPlatform, getCssHandlerOptions, getCssUserHandlerOptions, getRememberedCssSignature, getRememberedCssSources, isNativeAppStyleTarget, isWebGeneratorTarget, lastCssRawSourceHashByFile = /* @__PURE__ */ new Map(), lastCssResultByFile, lastCssSourceHashByFile, markCssAssetProcessed, metrics, normalizeViteCssCacheKey, onUpdate, opts, recordCssAssetResult, recordViteProcessedCssAssetResult, refreshRememberedCssSource, rootDir, runtimeState, setRememberedCssSignature, shouldInjectCssIntoMainFromOutput, shouldPreserveAppCssExtension, sourceRoot, styleHandler, timeTask, useIncrementalMode } = options;
3951
4147
  const rememberedReplayGroups = collectRememberedCssReplayGroups(getRememberedCssSources?.(), opts, rootDir, isWebGeneratorTarget, shouldPreserveAppCssExtension, sourceRoot, defaultStyleOutputExtension, bundleFiles);
3952
4148
  for (const [outputFile, rememberedGroup] of rememberedReplayGroups) {
3953
4149
  if (isHTMLRequest(outputFile) || options.opts.htmlMatcher(outputFile)) continue;
3954
- const refreshedRememberedGroup = await Promise.all(rememberedGroup.map(async (item) => ({
4150
+ const replayableRememberedGroup = (await Promise.all(rememberedGroup.map(async (item) => ({
3955
4151
  key: item.key,
3956
4152
  remembered: await refreshRememberedCssSource?.(item.remembered) ?? item.remembered
3957
- })));
3958
- const rememberedKeys = refreshedRememberedGroup.map((item) => item.key);
3959
- const rememberedCssSource = mergeRememberedCssSources(refreshedRememberedGroup.map((item) => item.remembered), outputFile);
4153
+ })))).filter(({ remembered }) => {
4154
+ const shouldSkip = shouldSkipRawRememberedCssSource(remembered.rawSource, remembered.sourceFile);
4155
+ if (shouldSkip) debug("css replay skip raw source style: %s -> %s", remembered.sourceFile, outputFile);
4156
+ return !shouldSkip;
4157
+ });
4158
+ const rememberedKeys = replayableRememberedGroup.map((item) => item.key);
4159
+ const rememberedCssSource = mergeRememberedCssSources(replayableRememberedGroup.map((item) => item.remembered), outputFile);
3960
4160
  if (!rememberedCssSource) continue;
3961
4161
  const { rawSource, sourceFile } = rememberedCssSource;
3962
4162
  const generatorRawSource = isWebGeneratorTarget ? rawSource : normalizeMiniProgramGeneratorCssSource(rawSource, outputFile);
@@ -4261,13 +4461,12 @@ function createSubpackageSourceCandidateScope(options) {
4261
4461
  function normalizeSourceCandidatePathKey(file) {
4262
4462
  return normalizeOutputPathKey(path.resolve(file));
4263
4463
  }
4264
- function resolveCurrentSourceCandidateSource(options) {
4265
- const { file, getSourceCandidateSource, getSourceCandidateSources, outDir, rootDir, sourceRoot } = options;
4464
+ function createSourceCandidateFiles(options) {
4465
+ const { file, outDir, rootDir, sourceRoot } = options;
4266
4466
  const cleanedFile = file.replace(/[?#].*$/, "");
4267
- const normalizedFile = normalizeOutputPathKey(cleanedFile);
4268
4467
  const absoluteFile = path.isAbsolute(cleanedFile) ? cleanedFile : path.resolve(rootDir, cleanedFile);
4269
4468
  const relativeFromOutDir = normalizeOutputPathKey(path.relative(outDir, absoluteFile));
4270
- const sourceCandidates = [
4469
+ return [
4271
4470
  sourceRoot ? path.resolve(sourceRoot, file) : void 0,
4272
4471
  path.resolve(rootDir, file),
4273
4472
  path.resolve(path.dirname(outDir), file),
@@ -4276,6 +4475,33 @@ function resolveCurrentSourceCandidateSource(options) {
4276
4475
  !path.isAbsolute(relativeFromOutDir) && !relativeFromOutDir.startsWith("../") ? path.resolve(path.dirname(outDir), relativeFromOutDir) : void 0,
4277
4476
  file
4278
4477
  ];
4478
+ }
4479
+ function resolveCurrentSourceCandidateFile(options) {
4480
+ const sourceCandidates = createSourceCandidateFiles(options);
4481
+ for (const candidate of sourceCandidates) if (candidate && options.getSourceCandidateSource?.(candidate) !== void 0) return candidate;
4482
+ const normalizedFile = normalizeOutputPathKey(options.file.replace(/[?#].*$/, ""));
4483
+ let bestMatch;
4484
+ const normalizedSourceCandidates = sourceCandidates.filter((candidate) => Boolean(candidate)).map((candidate) => ({
4485
+ absolute: path.isAbsolute(candidate),
4486
+ key: normalizeSourceCandidatePathKey(candidate)
4487
+ }));
4488
+ for (const [sourceFile] of options.getSourceCandidateSources?.() ?? []) {
4489
+ const normalizedSourceFile = normalizeSourceCandidatePathKey(sourceFile);
4490
+ let score = normalizedSourceCandidates.reduce((current, candidate) => {
4491
+ return normalizedSourceFile === candidate.key ? Math.max(current, candidate.absolute ? 100 : 80) : current;
4492
+ }, 0);
4493
+ if (normalizedSourceFile.endsWith(`/${normalizedFile}`)) score = Math.max(score, 20);
4494
+ if (score > (bestMatch?.score ?? 0)) bestMatch = {
4495
+ file: sourceFile,
4496
+ score
4497
+ };
4498
+ }
4499
+ return bestMatch?.file;
4500
+ }
4501
+ function resolveCurrentSourceCandidateSource(options) {
4502
+ const { file, getSourceCandidateSource, getSourceCandidateSources } = options;
4503
+ const normalizedFile = normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
4504
+ const sourceCandidates = createSourceCandidateFiles(options);
4279
4505
  const explicitSource = sourceCandidates.reduce((source, candidate) => {
4280
4506
  if (source || !candidate) return source;
4281
4507
  return getSourceCandidateSource?.(candidate);
@@ -4534,102 +4760,6 @@ function createBundleTaskTimer(recordTimingDetail) {
4534
4760
  };
4535
4761
  }
4536
4762
  //#endregion
4537
- //#region src/bundlers/vite/generate-bundle/transform-filter.ts
4538
- function toArray(value) {
4539
- return Array.isArray(value) ? value : value === void 0 ? [] : [value];
4540
- }
4541
- function normalizeSourceId(id) {
4542
- const file = cleanUrl(id);
4543
- return path.isAbsolute(file) ? path.resolve(file) : void 0;
4544
- }
4545
- function collectChunkModuleIds$1(chunk) {
4546
- const ids = /* @__PURE__ */ new Set();
4547
- for (const id of chunk.moduleIds ?? []) {
4548
- const normalized = normalizeSourceId(id);
4549
- if (normalized) ids.add(normalized);
4550
- }
4551
- for (const id of Object.keys(chunk.modules ?? {})) {
4552
- const normalized = normalizeSourceId(id);
4553
- if (normalized) ids.add(normalized);
4554
- }
4555
- return ids;
4556
- }
4557
- function collectAssetSourceIds(asset, fallbackFile, rootDir) {
4558
- const ids = /* @__PURE__ */ new Set();
4559
- const sourceCandidates = [asset.originalFileName, ...asset.originalFileNames ?? []].filter((candidate) => typeof candidate === "string" && candidate.length > 0);
4560
- const candidates = sourceCandidates.length > 0 ? sourceCandidates : [fallbackFile];
4561
- for (const candidate of candidates) {
4562
- if (typeof candidate !== "string" || candidate.length === 0) continue;
4563
- const cleanCandidate = cleanUrl(candidate);
4564
- const resolved = path.isAbsolute(cleanCandidate) ? path.resolve(cleanCandidate) : path.resolve(rootDir, cleanCandidate);
4565
- ids.add(resolved);
4566
- }
4567
- return ids;
4568
- }
4569
- function isStringRuleMatched(rule, id, rootDir) {
4570
- const normalizedId = slash(id);
4571
- const normalizedRule = slash(rule);
4572
- if (path.isAbsolute(rule)) return micromatch.isMatch(normalizedId, normalizedRule);
4573
- const relative = slash(path.relative(rootDir, id));
4574
- return relative.length > 0 && !relative.startsWith("../") && !path.isAbsolute(relative) && micromatch.isMatch(relative, normalizedRule);
4575
- }
4576
- function isRuleMatched(rule, id, rootDir) {
4577
- if (typeof rule === "string") return isStringRuleMatched(rule, id, rootDir);
4578
- if (rule instanceof RegExp) {
4579
- rule.lastIndex = 0;
4580
- return rule.test(slash(id));
4581
- }
4582
- return rule(id) === true;
4583
- }
4584
- function createTransformMatcher(rules, rootDir) {
4585
- const normalizedRules = toArray(rules);
4586
- if (normalizedRules.length === 0) return;
4587
- return (id) => normalizedRules.some((rule) => isRuleMatched(rule, id, rootDir));
4588
- }
4589
- function shouldSkipSourceIds(sourceIds, filter) {
4590
- if (sourceIds.size === 0) return false;
4591
- if (filter.exclude) {
4592
- let excluded = true;
4593
- for (const id of sourceIds) if (!filter.exclude(id)) {
4594
- excluded = false;
4595
- break;
4596
- }
4597
- if (excluded) return true;
4598
- }
4599
- if (filter.include) {
4600
- for (const id of sourceIds) if (filter.include(id)) return false;
4601
- return true;
4602
- }
4603
- return false;
4604
- }
4605
- function createTransformFilter(options, rootDir) {
4606
- const include = createTransformMatcher(options?.include, rootDir);
4607
- const exclude = createTransformMatcher(options?.exclude, rootDir);
4608
- if (!include && !exclude) return;
4609
- return {
4610
- include,
4611
- exclude
4612
- };
4613
- }
4614
- function shouldSkipViteJsChunkTransform(chunk, filter) {
4615
- if (!filter) return false;
4616
- return shouldSkipSourceIds(collectChunkModuleIds$1(chunk), filter);
4617
- }
4618
- function shouldSkipViteAssetTransform(asset, file, rootDir, filter) {
4619
- if (!filter) return false;
4620
- return shouldSkipSourceIds(collectAssetSourceIds(asset, file, rootDir), filter);
4621
- }
4622
- function createRuleSignature(rules) {
4623
- return toArray(rules).map((rule) => {
4624
- if (typeof rule === "string") return `s:${rule}`;
4625
- if (rule instanceof RegExp) return `r:${rule.source}/${rule.flags}`;
4626
- return "f";
4627
- }).join("|") || "none";
4628
- }
4629
- function createTransformFilterSignature(options) {
4630
- return [`include:${createRuleSignature(options?.include)}`, `exclude:${createRuleSignature(options?.exclude)}`].join(";");
4631
- }
4632
- //#endregion
4633
4763
  //#region src/bundlers/vite/weapp-vite-config.ts
4634
4764
  function resolveSourceRootCandidate(root, value) {
4635
4765
  if (typeof value !== "string" || value.trim().length === 0) return;
@@ -4750,8 +4880,11 @@ function createGenerateBundleHook(context) {
4750
4880
  })
4751
4881
  });
4752
4882
  return async function generateBundle(_opt, bundle) {
4883
+ if (context.shouldProcessBundle?.() === false) return;
4884
+ const processMarkupAndScripts = context.processMarkupAndScripts !== false;
4885
+ const processStyles = context.shouldProcessStyles?.() ?? context.processStyles !== false;
4753
4886
  const addWatchFile = (id) => this.addWatchFile?.(id);
4754
- const { opts, runtimeState, ensureBundleRuntimeClassSet, debug, getResolvedConfig, markCssAssetProcessed, isCssAssetProcessed, isViteProcessedCssAsset, recordCssAssetResult, recordViteProcessedCssAssetResult, getViteProcessedCssAssetResults, getViteProcessedCssAssetResult, getSourceCandidates, getSourceCandidateSource, getSourceCandidateSources, getSourceCandidatesForEntries, getSourceCandidateSourcesForEntries, waitForSourceCandidateSyncs, rememberCssSource, refreshRememberedCssSource, getRememberedCssSources, getRememberedCssSignature, setRememberedCssSignature, getKnownCssSource, getKnownSfcSource, getOriginalCssLayerSource, recordGeneratorCandidates, pruneViteCssCaches, getViteCssCacheStats, hmrTimingRecorder } = context;
4887
+ const { opts, runtimeState, ensureBundleRuntimeClassSet, debug, getResolvedConfig, markCssAssetProcessed, isCssAssetProcessed, isViteProcessedCssAsset, recordCssAssetResult, recordViteProcessedCssAssetResult, getViteProcessedCssAssetResults, getViteProcessedCssAssetResult, getSourceCandidates, getSourceCandidateSource, getSourceCandidateSources, extractSourceCandidates, getSourceCandidatesForEntries, getSourceCandidateSourcesForEntries, waitForSourceCandidateSyncs, rememberCssSource, refreshRememberedCssSource, getRememberedCssSources, getRememberedCssSignature, setRememberedCssSignature, getKnownCssSource, getKnownSfcSource, getOriginalCssLayerSource, recordGeneratorCandidates, pruneViteCssCaches, getViteCssCacheStats, hmrTimingRecorder } = context;
4755
4888
  const getBundlerSfcSource = (sourceFile) => {
4756
4889
  const code = this.getModuleInfo?.(sourceFile)?.code;
4757
4890
  return typeof code === "string" && hasSfcStyleSources(code) ? code : void 0;
@@ -4969,18 +5102,6 @@ function createGenerateBundleHook(context) {
4969
5102
  return !normalizeOutputPathKey(entryOutputFile.replace(/[?#].*$/, "")).includes("/") || currentSubpackageRoots != null && !isSubpackageOutputFile(entryOutputFile, currentSubpackageRoots);
4970
5103
  });
4971
5104
  };
4972
- const { createScopedSourceCandidateGetter, createScopedSourceCandidateSourceGetter, shouldExcludeSubpackageSourceCandidates, shouldInjectCssIntoMainFromOutput } = createSubpackageSourceCandidateScope({
4973
- cssSourceFiles: configuredTailwindV4CssSourceEntriesForScope.map((entry) => entry.file),
4974
- getSourceCandidateSourcesForEntries,
4975
- getSourceCandidatesForEntries,
4976
- projectRoot: opts.tailwindcssRuntimeOptions?.projectRoot,
4977
- rootDir,
4978
- snapshot,
4979
- sourceRoot,
4980
- subpackageRoots: currentSubpackageRoots,
4981
- tailwindcssBasedir: opts.tailwindcssBasedir,
4982
- useIncrementalMode
4983
- });
4984
5105
  recordTimingDetail("snapshot", snapshotStart);
4985
5106
  const useBundleRuntimeClassSet = !isWebGeneratorTarget;
4986
5107
  const forceRuntimeRefreshBySource = useIncrementalMode && hasRuntimeAffectingSourceChanges(snapshot.runtimeAffectingChangedByType);
@@ -4994,11 +5115,41 @@ function createGenerateBundleHook(context) {
4994
5115
  const sourceCandidateWaitStart = performance.now();
4995
5116
  await waitForSourceCandidateSyncs?.();
4996
5117
  recordTimingDetail("sourceCandidates.wait", sourceCandidateWaitStart);
4997
- const sourceCandidates = getSourceCandidates?.() ?? /* @__PURE__ */ new Set();
5118
+ const transformFilter = createTransformFilter(opts.transform, rootDir);
5119
+ const bundleMarkupCandidates = await collectBundleMarkupCandidates({
5120
+ extractSourceCandidates: processMarkupAndScripts && !isWebGeneratorTarget ? extractSourceCandidates : void 0,
5121
+ previousCandidatesByFile: useIncrementalMode ? state.bundleMarkupCandidatesByFile : void 0,
5122
+ preserveMissingFiles: useIncrementalMode && snapshot.hasOmittedKnownFiles,
5123
+ resolveSourceCandidateFile: (file) => resolveCurrentSourceCandidateFile({
5124
+ file,
5125
+ getSourceCandidateSource,
5126
+ getSourceCandidateSources,
5127
+ outDir,
5128
+ rootDir,
5129
+ sourceRoot
5130
+ }),
5131
+ rootDir,
5132
+ snapshot,
5133
+ transformFilter
5134
+ });
5135
+ const getCombinedSourceCandidatesForEntries = getSourceCandidatesForEntries || bundleMarkupCandidates.values.size > 0 ? (entries, options) => /* @__PURE__ */ new Set([...getSourceCandidatesForEntries?.(entries, options) ?? [], ...bundleMarkupCandidates.valuesForEntries(entries, options)]) : void 0;
5136
+ const sourceCandidates = /* @__PURE__ */ new Set([...getSourceCandidates?.() ?? [], ...bundleMarkupCandidates.values]);
5137
+ const { createScopedSourceCandidateGetter, createScopedSourceCandidateSourceGetter, shouldExcludeSubpackageSourceCandidates, shouldInjectCssIntoMainFromOutput } = createSubpackageSourceCandidateScope({
5138
+ cssSourceFiles: configuredTailwindV4CssSourceEntriesForScope.map((entry) => entry.file),
5139
+ getSourceCandidateSourcesForEntries,
5140
+ getSourceCandidatesForEntries: getCombinedSourceCandidatesForEntries,
5141
+ projectRoot: opts.tailwindcssRuntimeOptions?.projectRoot,
5142
+ rootDir,
5143
+ snapshot,
5144
+ sourceRoot,
5145
+ subpackageRoots: currentSubpackageRoots,
5146
+ tailwindcssBasedir: opts.tailwindcssBasedir,
5147
+ useIncrementalMode
5148
+ });
4998
5149
  const createScopedGeneratorRuntime$1 = (outputFile, cssHandlerOptions, runtime, rawSource, sourceFile) => createScopedGeneratorRuntime({
4999
5150
  cssHandlerOptions,
5000
5151
  fallbackRuntime: runtime,
5001
- getSourceCandidatesForEntries,
5152
+ getSourceCandidatesForEntries: getCombinedSourceCandidatesForEntries,
5002
5153
  majorVersion: runtimeState.tailwindRuntime.majorVersion,
5003
5154
  outputFile,
5004
5155
  rawSource,
@@ -5008,7 +5159,6 @@ function createGenerateBundleHook(context) {
5008
5159
  });
5009
5160
  const jsEntries = snapshot.jsEntries;
5010
5161
  const getJsEntry = createJsEntryResolver(jsEntries);
5011
- const transformFilter = createTransformFilter(opts.transform, rootDir);
5012
5162
  const transformFilterSignature = createTransformFilterSignature(opts.transform);
5013
5163
  const moduleGraphOptions = createBundleModuleGraphOptions(outDir, jsEntries);
5014
5164
  const hasRuntimeAffectingChanges = hasRuntimeAffectingSourceChanges(snapshot.runtimeAffectingChangedByType);
@@ -5158,7 +5308,7 @@ function createGenerateBundleHook(context) {
5158
5308
  const jsTaskFactories = [];
5159
5309
  for (const entry of snapshot.entries) {
5160
5310
  const { file, output: originalSource, source: originalEntrySource, type } = entry;
5161
- if (type === "html" && originalSource.type === "asset") {
5311
+ if (processMarkupAndScripts && type === "html" && originalSource.type === "asset") {
5162
5312
  metrics.html.total++;
5163
5313
  if (isWebGeneratorTarget) {
5164
5314
  debug("html skip web target: %s", file);
@@ -5197,7 +5347,7 @@ function createGenerateBundleHook(context) {
5197
5347
  });
5198
5348
  continue;
5199
5349
  }
5200
- if (type === "css" && originalSource.type === "asset") {
5350
+ if (processStyles && type === "css" && originalSource.type === "asset") {
5201
5351
  metrics.css.total++;
5202
5352
  const assetSourceFile = resolveAssetSourceFile(originalSource, file);
5203
5353
  const rawSource = normalizeRelativeCssConfigDirectives(originalEntrySource, assetSourceFile, outDir, opts);
@@ -5462,6 +5612,11 @@ function createGenerateBundleHook(context) {
5462
5612
  }
5463
5613
  }
5464
5614
  if (currentRawSourceHasExplicitScanContext) rememberedCssSources = rememberedCssSources.filter((remembered) => remembered.rawSource.includes("@source") || remembered.rawSource.includes("@config"));
5615
+ rememberedCssSources = rememberedCssSources.filter((remembered) => {
5616
+ const shouldSkip = shouldSkipRawRememberedCssSource(remembered.rawSource, remembered.sourceFile);
5617
+ if (shouldSkip) debug("css skip raw remembered source style: %s -> %s", remembered.sourceFile, outputFile);
5618
+ return !shouldSkip;
5619
+ });
5465
5620
  let rememberedCssSource = mergeRememberedCssSources(rememberedCssSources, outputFile);
5466
5621
  if (rememberedCssSource && viteProcessedCssAsset && outputCssHandlerOptions.isMainChunk !== true && configuredTailwindV4CssSourceFileKeysForScope.has(normalizeConfiguredTailwindV4CssEntryFileKey(rememberedCssSource.sourceFile))) {
5467
5622
  const matchedOutputFile = resolveMatchedOutputFileForCurrentAsset(rememberedCssSource.sourceFile);
@@ -5713,6 +5868,7 @@ function createGenerateBundleHook(context) {
5713
5868
  continue;
5714
5869
  }
5715
5870
  if (type !== "js") continue;
5871
+ if (!processMarkupAndScripts) continue;
5716
5872
  if (!shouldTransformJsBundle) {
5717
5873
  debug("js skip web target: %s", file);
5718
5874
  continue;
@@ -5746,7 +5902,7 @@ function createGenerateBundleHook(context) {
5746
5902
  useIncrementalMode
5747
5903
  });
5748
5904
  }
5749
- if (shouldProcessTailwindGeneration || useIncrementalMode || isNativeAppStyleTarget) await processRememberedCssReplay({
5905
+ if (processStyles && (shouldProcessTailwindGeneration || useIncrementalMode || isNativeAppStyleTarget)) await processRememberedCssReplay({
5750
5906
  addWatchFile,
5751
5907
  activeViteCssCacheFiles,
5752
5908
  bundle,
@@ -5808,7 +5964,7 @@ function createGenerateBundleHook(context) {
5808
5964
  generatorRuntime,
5809
5965
  getCssHandlerOptions,
5810
5966
  getSourceCandidateSourcesForEntries,
5811
- getSourceCandidatesForEntries,
5967
+ getSourceCandidatesForEntries: getCombinedSourceCandidatesForEntries,
5812
5968
  getViteCssCacheStats,
5813
5969
  getViteProcessedCssAssetResults,
5814
5970
  hmrTimingRecorder,
@@ -5848,6 +6004,7 @@ function createGenerateBundleHook(context) {
5848
6004
  transformWebTargetCss,
5849
6005
  useIncrementalMode
5850
6006
  });
6007
+ state.bundleMarkupCandidatesByFile = bundleMarkupCandidates.candidatesByFile;
5851
6008
  };
5852
6009
  }
5853
6010
  //#endregion
@@ -6067,10 +6224,15 @@ function createViteCssFinalizerOutputPlugin(context) {
6067
6224
  const file = output.fileName || bundleFile;
6068
6225
  const rawSource = output.source.toString();
6069
6226
  if (isViteProcessedCssAsset?.(output, file)) {
6070
- const nextCss = annotateCss(finalizeWebCss(stripBundlerGeneratedCssMarkers(rawSource), {
6227
+ const cleanRawSource = stripBundlerGeneratedCssMarkers(rawSource);
6228
+ const cssHandlerOptions = createCssHandlerOptions(opts, runtimeState.tailwindRuntime.majorVersion, file, outDir, cssPipelineStrategy?.getCssHandlerExtraOptions?.({
6071
6229
  ...createCssPipelineContext(file),
6072
6230
  file
6073
- }, cssPipelineStrategy));
6231
+ }) ?? {});
6232
+ const nextCss = annotateCss(generatorBranch.isWeb ? finalizeWebCss(cleanRawSource, {
6233
+ ...createCssPipelineContext(file),
6234
+ file
6235
+ }, cssPipelineStrategy) : (await opts.styleHandler(cleanRawSource, cssHandlerOptions)).css);
6074
6236
  output.source = nextCss;
6075
6237
  markCssAssetProcessed(output, file);
6076
6238
  recordCssAssetResult?.(file, nextCss);
@@ -6886,52 +7048,74 @@ function isViteServeStyleRequest(id, command) {
6886
7048
  function isViteServeCssRootRequest(id, command) {
6887
7049
  return command === "serve" && isSourceStyleRequest(id) && !SPECIAL_QUERY_RE$1.test(id) && !COMMON_JS_PROXY_RE.test(id);
6888
7050
  }
7051
+ function isViteBuildStyleRequest(id, command) {
7052
+ return command === "build" && isSourceStyleRequest(id) && !SPECIAL_QUERY_RE$1.test(id) && !COMMON_JS_PROXY_RE.test(id);
7053
+ }
6889
7054
  function isViteCssHmrModule(code, id, command) {
6890
7055
  return isViteServeStyleRequest(id, command) && VITE_CSS_HMR_MODULE_RE.test(code) && (/[?&](?:direct|vue)(?:&|$)/.test(id) || DEFERRED_CSS_HMR_QUERY_RE.test(id));
6891
7056
  }
6892
- function hasViteServeCssGenerationDirective(code) {
7057
+ function hasViteCssGenerationDirective(code) {
6893
7058
  return hasTailwindRootDirectives(code) || hasTailwindSourceDirectives(code, { importFallback: true }) || hasTailwindApplyDirective(code);
6894
7059
  }
6895
7060
  function hasViteServeCssRootDirective(code) {
6896
7061
  return hasTailwindRootDirectives(code);
6897
7062
  }
6898
- function createViteServeCssGenerationPlugins(options) {
6899
- return [{
6900
- name: `${vitePluginName}:generate:serve`,
6901
- apply: "serve",
6902
- enforce: "pre",
6903
- async transform(code, id) {
6904
- if (!options.shouldGenerate() || !isViteServeCssRootRequest(id, options.getCommand())) return;
6905
- if (!hasTailwindRootDirectives(code)) return;
6906
- if (DEFERRED_CSS_HMR_QUERY_RE.test(id)) return;
6907
- await options.onTailwindRootCss?.(id, code);
6908
- const generatedCss = await options.generateCss(id, code, this);
6909
- if (generatedCss === void 0 || generatedCss === code) return;
6910
- return {
6911
- code: generatedCss,
6912
- map: null
6913
- };
6914
- }
6915
- }, {
6916
- name: `${vitePluginName}:generate:serve-hmr`,
6917
- apply: "serve",
6918
- enforce: "post",
6919
- async transform(code, id) {
6920
- if (!options.shouldGenerate() || !isViteCssHmrModule(code, id, options.getCommand())) return;
6921
- const extracted = extractViteCssHmrModuleCss(code);
6922
- if (!extracted) return;
6923
- if (!hasViteServeCssGenerationDirective(extracted.css)) return;
6924
- if (hasViteServeCssRootDirective(extracted.css)) await options.onTailwindRootCss?.(id, extracted.css);
6925
- const generatedCss = await options.generateCss(id, extracted.css, this);
6926
- if (generatedCss === void 0 || generatedCss === extracted.css) return;
6927
- const nextCode = replaceViteCssHmrModuleCss(code, generatedCss);
6928
- if (nextCode === void 0 || nextCode === code) return;
6929
- return {
6930
- code: nextCode,
6931
- map: null
6932
- };
7063
+ function createViteCssGenerationPlugins(options) {
7064
+ return [
7065
+ {
7066
+ name: `${vitePluginName}:generate:serve`,
7067
+ apply: "serve",
7068
+ enforce: "pre",
7069
+ async transform(code, id) {
7070
+ if (!options.shouldGenerate() || !isViteServeCssRootRequest(id, options.getCommand())) return;
7071
+ if (!hasTailwindRootDirectives(code)) return;
7072
+ if (DEFERRED_CSS_HMR_QUERY_RE.test(id)) return;
7073
+ await options.onTailwindRootCss?.(id, code);
7074
+ const generatedCss = await options.generateCss(id, code, this);
7075
+ if (generatedCss === void 0 || generatedCss === code) return;
7076
+ return {
7077
+ code: generatedCss,
7078
+ map: null
7079
+ };
7080
+ }
7081
+ },
7082
+ {
7083
+ name: `${vitePluginName}:generate:build`,
7084
+ apply: "build",
7085
+ enforce: "pre",
7086
+ async transform(code, id) {
7087
+ if (!options.shouldGenerate() || options.shouldGenerateBuild?.() === false || !isViteBuildStyleRequest(id, options.getCommand())) return;
7088
+ if (!hasViteCssGenerationDirective(code)) return;
7089
+ if (hasViteServeCssRootDirective(code)) await options.onTailwindRootCss?.(id, code);
7090
+ const generatedCss = await options.generateCss(id, code, this);
7091
+ if (generatedCss === void 0 || generatedCss === code) return;
7092
+ return {
7093
+ code: generatedCss,
7094
+ map: null
7095
+ };
7096
+ }
7097
+ },
7098
+ {
7099
+ name: `${vitePluginName}:generate:serve-hmr`,
7100
+ apply: "serve",
7101
+ enforce: "post",
7102
+ async transform(code, id) {
7103
+ if (!options.shouldGenerate() || !isViteCssHmrModule(code, id, options.getCommand())) return;
7104
+ const extracted = extractViteCssHmrModuleCss(code);
7105
+ if (!extracted) return;
7106
+ if (!hasViteCssGenerationDirective(extracted.css)) return;
7107
+ if (hasViteServeCssRootDirective(extracted.css)) await options.onTailwindRootCss?.(id, extracted.css);
7108
+ const generatedCss = await options.generateCss(id, extracted.css, this);
7109
+ if (generatedCss === void 0 || generatedCss === extracted.css) return;
7110
+ const nextCode = replaceViteCssHmrModuleCss(code, generatedCss);
7111
+ if (nextCode === void 0 || nextCode === code) return;
7112
+ return {
7113
+ code: nextCode,
7114
+ map: null
7115
+ };
7116
+ }
6933
7117
  }
6934
- }];
7118
+ ];
6935
7119
  }
6936
7120
  //#endregion
6937
7121
  //#region src/bundlers/vite/serve-js-transform.ts
@@ -6996,6 +7180,40 @@ function resolveImplicitTailwindcssBasedirFromViteRoot(root) {
6996
7180
  return resolvedRoot;
6997
7181
  }
6998
7182
  //#endregion
7183
+ //#region src/bundlers/vite/watch-css-post.ts
7184
+ const wrappedCssPostPlugins = /* @__PURE__ */ new WeakSet();
7185
+ function isWebOrNativeAppPlatform$1(platform) {
7186
+ return platform === "h5" || platform === "web" || platform?.startsWith("web-") === true || platform === "app" || platform === "app-plus" || platform?.startsWith("app-") === true;
7187
+ }
7188
+ function shouldAdaptFrameworkWatchCssBeforeCache(options) {
7189
+ return options.enabled && options.ownsTailwindGeneration && options.isWatchBuild && (options.platform ? !isWebOrNativeAppPlatform$1(options.platform) : !options.isWebGeneratorBranch);
7190
+ }
7191
+ function resolveTransformHandler(plugin) {
7192
+ const hook = plugin.transform;
7193
+ if (typeof hook === "function") return hook;
7194
+ if (hook && typeof hook === "object" && typeof hook.handler === "function") return hook.handler;
7195
+ }
7196
+ /**
7197
+ * 在框架的 CSS post hook 持久化样式前完成转换,保证 watch 重放缓存时不会重新输出原始 CSS。
7198
+ */
7199
+ function wrapViteCssPostTransform(config, transformCss) {
7200
+ const plugin = config.plugins?.find((candidate) => candidate.name === "vite:css-post");
7201
+ if (!plugin || wrappedCssPostPlugins.has(plugin)) return false;
7202
+ const originalHandler = resolveTransformHandler(plugin);
7203
+ if (!originalHandler) return false;
7204
+ const wrappedHandler = async function(code, id, ...args) {
7205
+ const transformedCss = await transformCss(code, id);
7206
+ return originalHandler.call(this, transformedCss, id, ...args);
7207
+ };
7208
+ const originalHook = plugin.transform;
7209
+ plugin.transform = originalHook && typeof originalHook === "object" ? {
7210
+ ...originalHook,
7211
+ handler: wrappedHandler
7212
+ } : wrappedHandler;
7213
+ wrappedCssPostPlugins.add(plugin);
7214
+ return true;
7215
+ }
7216
+ //#endregion
6999
7217
  //#region src/bundlers/vite/shared/create-framework-plugins.ts
7000
7218
  const debug = createDebug();
7001
7219
  const weappTailwindcssPackageDir = resolvePackageDir("weapp-tailwindcss");
@@ -7605,12 +7823,23 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
7605
7823
  getMajorVersion: () => runtimeState.tailwindRuntime.majorVersion,
7606
7824
  moduleGraph: void 0
7607
7825
  });
7826
+ const shouldAdaptFrameworkWatchCss = () => {
7827
+ const platform = resolveViteStylePlatform();
7828
+ return shouldAdaptFrameworkWatchCssBeforeCache({
7829
+ enabled: frameworkBranch.adaptWatchCssBeforeFrameworkCache === true,
7830
+ ownsTailwindGeneration: shouldOwnTailwindGeneration,
7831
+ isWatchBuild: isWatchBuild(),
7832
+ isWebGeneratorBranch: resolveCurrentGeneratorBranch().isWeb,
7833
+ platform
7834
+ });
7835
+ };
7608
7836
  const generateTailwindCssForVitePipeline = async (id, code, hookContext) => {
7609
7837
  if (!shouldOwnTailwindGeneration) return;
7610
7838
  await runtimeState.readyPromise;
7611
7839
  await waitForSourceCandidateSyncs();
7612
7840
  const file = cleanUrl(id);
7613
- const requestFile = isCSSRequest(id) ? id === file ? resolveSfcStyleRequestFromKnownSource(file, cssMemory.getKnownSfcSource(file), code) : id : file;
7841
+ const inferredSfcStyleRequest = isSfcStyleSourceFile(file) ? resolveSfcStyleRequestFromKnownSource(file, cssMemory.getKnownSfcSource(file), code) : file;
7842
+ const requestFile = isCSSRequest(id) ? inferredSfcStyleRequest === file ? id : inferredSfcStyleRequest : inferredSfcStyleRequest;
7614
7843
  if (!isCSSRequest(requestFile) || opts.htmlMatcher(file) || isHTMLRequest(file)) return;
7615
7844
  const generatorCode = normalizeEmptyTailwindCustomVariants(code);
7616
7845
  const rootDir = resolvedConfig?.root ? path.resolve(resolvedConfig.root) : process$1.cwd();
@@ -7682,7 +7911,7 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
7682
7911
  }) ?? true);
7683
7912
  const previousCss = pendingHmrChange && !forceFullHmrCssRegeneration ? cleanGeneratedCssByFile.get(fileKey) : void 0;
7684
7913
  const previousGeneratorCss = previousCss && !currentGeneratorBranch.isWeb ? normalizeMiniProgramGeneratorCssSource(previousCss, outputFile) : previousCss;
7685
- const generated = await hmrTimingRecorder.measure("generateCss.serve", () => generateTailwindV4Css({
7914
+ const generated = await hmrTimingRecorder.measure(`generateCss.${resolvedConfig?.command ?? "unknown"}`, () => generateTailwindV4Css({
7686
7915
  opts,
7687
7916
  runtimeState,
7688
7917
  runtime,
@@ -7699,6 +7928,7 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
7699
7928
  previousCss: previousGeneratorCss,
7700
7929
  previousClassSet: pendingHmrChange && !forceFullHmrCssRegeneration ? generatedClassSetByFile.get(fileKey) : void 0,
7701
7930
  deferEmptyScopedCssSource: shouldDeferEmptyScopedCssSource,
7931
+ deferCssAdaptation: !currentGeneratorBranch.isWeb && !shouldAdaptFrameworkWatchCss(),
7702
7932
  disableSourceScan: false,
7703
7933
  restoreLocalCssImports: !currentGeneratorBranch.isWeb
7704
7934
  }), {
@@ -7774,7 +8004,7 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
7774
8004
  weappTailwindcssDirPosix
7775
8005
  });
7776
8006
  if (disabledOptions.plugin) return rewritePlugins.length ? rewritePlugins : void 0;
7777
- const generateBundleHook = createGenerateBundleHook({
8007
+ const generateBundleContext = {
7778
8008
  opts,
7779
8009
  runtimeState,
7780
8010
  ensureRuntimeClassSet,
@@ -7791,6 +8021,11 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
7791
8021
  getSourceCandidates,
7792
8022
  getSourceCandidateSource: (file) => sourceCandidateCollector.source(file),
7793
8023
  getSourceCandidateSources: () => sourceCandidateCollector.sources(),
8024
+ extractSourceCandidates: (file, source) => extractCandidatesFromSource(source, path.extname(cleanUrl(file)).slice(1) || "html", {
8025
+ bareArbitraryValues: opts.arbitraryValues?.bareArbitraryValues,
8026
+ customAttributesEntities,
8027
+ disabledDefaultTemplateHandler
8028
+ }),
7794
8029
  getSourceCandidatesForEntries,
7795
8030
  getSourceCandidateSourcesForEntries,
7796
8031
  waitForSourceCandidateSyncs,
@@ -7808,6 +8043,16 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
7808
8043
  hmrTimingRecorder,
7809
8044
  cssPipelineStrategy: frameworkCssPipelineStrategy,
7810
8045
  frameworkRootImportShellTargetByFile
8046
+ };
8047
+ const shouldSplitGenerateBundlePhases = () => opts.appType === "weapp-vite" && getResolvedConfig()?.mode !== "production";
8048
+ const preGenerateBundleHook = createGenerateBundleHook({
8049
+ ...generateBundleContext,
8050
+ processMarkupAndScripts: false,
8051
+ shouldProcessBundle: shouldSplitGenerateBundlePhases
8052
+ });
8053
+ const generateBundleHook = createGenerateBundleHook({
8054
+ ...generateBundleContext,
8055
+ shouldProcessStyles: () => !shouldSplitGenerateBundlePhases()
7811
8056
  });
7812
8057
  const cssFinalizerOutputPlugin = createViteCssFinalizerOutputPlugin({
7813
8058
  opts,
@@ -7854,6 +8099,21 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
7854
8099
  styleHandler,
7855
8100
  uniAppX
7856
8101
  }) ?? [];
8102
+ const installFrameworkWatchCssCacheAdapter = async (config) => {
8103
+ if (!shouldAdaptFrameworkWatchCss()) return;
8104
+ if (wrapViteCssPostTransform(config, async (css, id) => {
8105
+ if (!isCSSRequest(id)) return css;
8106
+ if (hasBundlerGeneratedCssMarker(css)) {
8107
+ debug("preserve adapted generated css before uni-app watch cache: %s", id);
8108
+ return css;
8109
+ }
8110
+ const file = cleanUrl(id);
8111
+ const styleRequest = isSfcStyleSourceFile(file) ? resolveSfcStyleRequestFromKnownSource(file, cssMemory.getKnownSfcSource(file), css, id) : id;
8112
+ const transformedCss = (await styleHandler(css, transformCssHandlerOptions.getCssHandlerOptions(styleRequest))).css;
8113
+ debug("adapt css before uni-app watch cache: %s inputRaw=%s outputRaw=%s", id, css.includes("\\[") || css.includes("\\:"), transformedCss.includes("\\[") || transformedCss.includes("\\:"));
8114
+ return transformedCss;
8115
+ })) debug("adapt uni-app watch css before vite:css-post cache");
8116
+ };
7857
8117
  const plugins = [
7858
8118
  ...rewritePlugins,
7859
8119
  {
@@ -7972,13 +8232,15 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
7972
8232
  await hmrTimingRecorder.measure("sourceCandidates.buildStart", async () => {
7973
8233
  await prepareTailwindGeneration();
7974
8234
  }, { emit: false });
7975
- }
8235
+ },
8236
+ generateBundle: preGenerateBundleHook
7976
8237
  },
7977
- ...createViteServeCssGenerationPlugins({
8238
+ ...createViteCssGenerationPlugins({
7978
8239
  generateCss: generateTailwindCssForVitePipeline,
7979
8240
  getCommand: () => resolvedConfig?.command,
7980
8241
  onTailwindRootCss: registerTailwindRootCss,
7981
- shouldGenerate: () => shouldOwnTailwindGeneration
8242
+ shouldGenerate: () => shouldOwnTailwindGeneration,
8243
+ shouldGenerateBuild: () => resolveCurrentGeneratorBranch().isWeb
7982
8244
  }),
7983
8245
  createViteServeJsTransformPlugin({
7984
8246
  createHandlerOptions: (file) => serveJsHandlerOptions(file, frameworkCssPipelineStrategy?.getServeJsHandlerOptions?.({
@@ -7990,6 +8252,13 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
7990
8252
  shouldTransform: () => shouldOwnTailwindGeneration && (frameworkCssPipelineStrategy?.shouldTransformServeJs?.(createCssPipelineContext()) ?? !resolveCurrentGeneratorBranch().isWeb),
7991
8253
  transformRuntime: ensureRuntimeClassSet
7992
8254
  }),
8255
+ {
8256
+ name: `${vitePluginName}:watch-css-cache`,
8257
+ configResolved: {
8258
+ order: "post",
8259
+ handler: installFrameworkWatchCssCacheAdapter
8260
+ }
8261
+ },
7993
8262
  {
7994
8263
  name: `${vitePluginName}:post`,
7995
8264
  enforce: "post",
@@ -7997,7 +8266,10 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
7997
8266
  if (!shouldOwnTailwindGeneration) return;
7998
8267
  if (Array.isArray(config.plugins)) {
7999
8268
  const removed = disableAndRemoveTailwindVitePlugins(config.plugins);
8000
- if (removed > 0) debug("disable official tailwind vite plugins in generator mode: %d", removed);
8269
+ if (removed > 0) {
8270
+ logger.warn("检测到 @tailwindcss/vite,生成模式下已移除该插件以避免 Tailwind CSS 重复生成。");
8271
+ debug("disable official tailwind vite plugins in generator mode: %d", removed);
8272
+ }
8001
8273
  }
8002
8274
  const root = config.root ? path.resolve(config.root) : process$1.cwd();
8003
8275
  const baseConfig = { resolve: { alias: [{
@@ -8051,7 +8323,10 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
8051
8323
  const postcssPlugins = config.css.postcss.plugins;
8052
8324
  if (shouldOwnTailwindGeneration) {
8053
8325
  const removed = removeTailwindPostcssPlugins(postcssPlugins);
8054
- if (removed > 0) debug("remove official tailwind postcss plugins in generator mode: %d", removed);
8326
+ if (removed > 0) {
8327
+ logger.warn("检测到 @tailwindcss/postcss,生成模式下已移除该插件以避免 Tailwind CSS 重复生成。");
8328
+ debug("remove official tailwind postcss plugins in generator mode: %d", removed);
8329
+ }
8055
8330
  }
8056
8331
  }
8057
8332
  }, { emit: false });
@@ -8176,6 +8451,7 @@ const uniAppCssPipelineStrategy = {
8176
8451
  function createUniAppVitePlugins(options = {}) {
8177
8452
  return createViteFrameworkPlugins(options, {
8178
8453
  frameworkName: "uni-app",
8454
+ adaptWatchCssBeforeFrameworkCache: true,
8179
8455
  cssPipelineStrategy: uniAppCssPipelineStrategy,
8180
8456
  styleInjectorDelegate: viteStyleInjectorDelegates.uniApp
8181
8457
  });
@@ -8301,6 +8577,7 @@ const uniAppXCssPipelineStrategy = {
8301
8577
  function createUniAppXVitePlugins(options = {}) {
8302
8578
  return createViteFrameworkPlugins(options, {
8303
8579
  frameworkName: "uni-app-x",
8580
+ adaptWatchCssBeforeFrameworkCache: true,
8304
8581
  cssPipelineStrategy: uniAppXCssPipelineStrategy,
8305
8582
  getExtraPluginPlatform: () => ({ isIosPlatform: resolveUniUtsPlatform().isAppIos }),
8306
8583
  styleInjectorDelegate: viteStyleInjectorDelegates.uniApp,