weapp-tailwindcss 5.1.9 → 5.1.11
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-CHk7V9EA.js → vite-DODC15Fr.js} +865 -254
- package/dist/{vite-ClpyoD9e.mjs → vite-oI2ReOic.mjs} +818 -207
- 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 +5 -5
- package/dist/generator-DaaFxR5V.js +0 -174
- package/dist/generator-DugIHBgl.mjs +0 -127
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { resolveImplicitAppTypeFromViteRoot } from "./framework.mjs";
|
|
2
|
-
import { $ as
|
|
3
|
-
import { a as resolveGeneratorRuntimeBranch, c as shouldUseNativeAppCssBranch, i as normalizeWeappTailwindcssGeneratorOptions, s as shouldUseMiniProgramCssBranch } from "./generator-DugIHBgl.mjs";
|
|
2
|
+
import { $ as normalizeTailwindSourceForGenerator, A as hasUserCssLayerBlocks, G as stripMiniProgramCssSpecificityPlaceholders, H as hasMiniProgramCssSpecificityPlaceholders, J as hasTailwindNonRootGenerationDirectives, K as hasLocalCssImport, M as normalizeEmptyTailwindCustomVariants, Nt as filterUnsupportedMiniProgramTailwindV4Candidates, Pt as omitUndefined, T as resolveTailwindcssOptions, X as hasTailwindSourceDirectives, Y as hasTailwindRootDirectives, Z as normalizeTailwindConfigDirectives, _t as getTailwindV4IncrementalGenerateCacheStats, a as resolveGeneratorRuntimeBranch, b as findNearestPackageRoot, c as shouldUseNativeAppCssBranch, dt as stripGeneratorPlaceholderMarkers, et as parseImportRequest, h as upsertTailwindV4CssSource, i as normalizeWeappTailwindcssGeneratorOptions, kt as resolveTailwindV4CssSourceBase, m as hasConfiguredTailwindV4CssRoots, p as filterTailwindV4CssSourceRoots, q as hasTailwindApplyDirective, s as shouldUseMiniProgramCssBranch, st as hasTailwindGeneratedCssMarkers, tt as removeTailwindSourceDirectives, v as isTailwindV4CssEntry, y as normalizeCssEntries } from "./generator-ROzBodj6.mjs";
|
|
4
3
|
import { o as resolveUniUtsPlatform } from "./utils-DodxWHGz.mjs";
|
|
5
|
-
import { C as normalizeFrameworkStylePlatform, S as createDebug, _ as toCustomAttributesEntities, a as vitePluginName, l as shouldSkipJsTransform, m as replaceWxml, n as normalizeStyleHandlerMajorVersion, t as getCompilerContext, v as collectRuntimeClassSet, x as refreshTailwindRuntimeState, y as createTailwindRuntimeReadyPromise } from "./context-
|
|
6
|
-
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-
|
|
7
|
-
import { E as
|
|
8
|
-
import { A as
|
|
4
|
+
import { C as normalizeFrameworkStylePlatform, S as createDebug, _ as toCustomAttributesEntities, a as vitePluginName, l as shouldSkipJsTransform, m as replaceWxml, n as normalizeStyleHandlerMajorVersion, t as getCompilerContext, v as collectRuntimeClassSet, x as refreshTailwindRuntimeState, y as createTailwindRuntimeReadyPromise } from "./context-DzkSFEVL.mjs";
|
|
5
|
+
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-hzy_WaC9.mjs";
|
|
6
|
+
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-DwtYJdwb.mjs";
|
|
7
|
+
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-CQ04hiox.mjs";
|
|
9
8
|
import { t as logger$1 } from "./logger-BNzxZbZj.mjs";
|
|
10
9
|
import fs, { existsSync, readFileSync, realpathSync } from "node:fs";
|
|
11
10
|
import path from "node:path";
|
|
@@ -541,8 +540,13 @@ function registerGeneratorDependencies$1(ctx, dependencies) {
|
|
|
541
540
|
}
|
|
542
541
|
//#endregion
|
|
543
542
|
//#region src/bundlers/vite/generate-bundle/css-assets.ts
|
|
544
|
-
function createCssAssetEmitter(context) {
|
|
543
|
+
function createCssAssetEmitter(context, bundle) {
|
|
545
544
|
return (fileName, source) => {
|
|
545
|
+
const existing = bundle?.[fileName];
|
|
546
|
+
if (existing && typeof existing === "object" && "type" in existing && existing.type === "asset") {
|
|
547
|
+
existing.source = source;
|
|
548
|
+
return existing;
|
|
549
|
+
}
|
|
546
550
|
if (context.emitFile) {
|
|
547
551
|
context.emitFile({
|
|
548
552
|
type: "asset",
|
|
@@ -652,9 +656,9 @@ function resolveReplayCssOutputFileFromSourceRoot(rootDir, file, sourceRoot) {
|
|
|
652
656
|
return outputFile;
|
|
653
657
|
}
|
|
654
658
|
function resolveViteCssOutputFile(file, opts, isWebGeneratorTarget, preserveCssExtension = false, styleOutputExtension, styleOutputFiles) {
|
|
655
|
-
if (isWebGeneratorTarget || preserveCssExtension || opts.cssMatcher(file) || !
|
|
656
|
-
const stem = file.replace(/[?#].*$/, "").replace(
|
|
657
|
-
return file.replace(
|
|
659
|
+
if (isWebGeneratorTarget || preserveCssExtension || opts.cssMatcher(file) || !CSS_SOURCE_OUTPUT_EXT_RE.test(file) || !isCSSRequest(file)) return file;
|
|
660
|
+
const stem = file.replace(/[?#].*$/, "").replace(CSS_SOURCE_OUTPUT_EXT_RE, "");
|
|
661
|
+
return file.replace(CSS_SOURCE_OUTPUT_EXT_RE, resolveMiniProgramStyleOutputExtension({
|
|
658
662
|
cssMatcher: opts.cssMatcher,
|
|
659
663
|
fallback: styleOutputExtension,
|
|
660
664
|
files: styleOutputFiles,
|
|
@@ -1651,6 +1655,10 @@ function resolveSourceStyleFileFromSiblingChunk(outputFile, snapshot, outputRoot
|
|
|
1651
1655
|
debug("source style sibling chunk skipped: no source style modules for %s -> %s", outputFile, siblingJsFile);
|
|
1652
1656
|
return;
|
|
1653
1657
|
}
|
|
1658
|
+
if (sourceFiles.length === 1) {
|
|
1659
|
+
debug("source style sibling chunk inferred from single css module: %s -> %s", outputFile, sourceFiles[0]);
|
|
1660
|
+
return sourceFiles[0];
|
|
1661
|
+
}
|
|
1654
1662
|
const scoredSources = sourceFiles.map((sourceFile) => ({
|
|
1655
1663
|
sourceFile,
|
|
1656
1664
|
score: scoreMatchingStyleFileBase(outputFile, sourceFile, outputRoot, sourceRoot)
|
|
@@ -1669,11 +1677,23 @@ function resolveSourceStyleSourceFromOutputFile(outputFile, snapshot, outputRoot
|
|
|
1669
1677
|
let sourceFile = resolveSourceStyleFileFromSiblingChunk(outputFile, snapshot, outputRoot, sourceRoot, debug);
|
|
1670
1678
|
let rawSource = sourceFile ? getSourceStyleSource?.(sourceFile) : void 0;
|
|
1671
1679
|
if (!sourceFile || !rawSource || !hasTailwindGenerationSourceForFile(sourceFile, rawSource)) {
|
|
1672
|
-
const
|
|
1680
|
+
const cachedSources = [...getSourceStyleSources?.() ?? []].filter(([file, source]) => CSS_SOURCE_OUTPUT_EXT_RE.test(file) && hasTailwindGenerationSourceForFile(file, source)).map(([file, source]) => ({
|
|
1673
1681
|
file,
|
|
1674
1682
|
source,
|
|
1675
|
-
score:
|
|
1676
|
-
|
|
1683
|
+
score: scoreTailwindV4CssSourceFileMatch(outputFile, file, {
|
|
1684
|
+
outputRoot,
|
|
1685
|
+
projectRoot: sourceRoot
|
|
1686
|
+
})
|
|
1687
|
+
}));
|
|
1688
|
+
const configuredSources = [...configuredSourceEntries ?? []].filter(([file, source]) => CSS_SOURCE_OUTPUT_EXT_RE.test(file) && hasTailwindGenerationSourceForFile(file, source)).map(([file, source]) => ({
|
|
1689
|
+
file,
|
|
1690
|
+
source,
|
|
1691
|
+
score: scoreTailwindV4CssSourceFileMatch(outputFile, file, {
|
|
1692
|
+
outputRoot,
|
|
1693
|
+
projectRoot: sourceRoot
|
|
1694
|
+
})
|
|
1695
|
+
}));
|
|
1696
|
+
const scoredSources = [...cachedSources, ...configuredSources].filter((item) => item.score > 0).sort((a, b) => b.score - a.score);
|
|
1677
1697
|
const bestScore = scoredSources[0]?.score;
|
|
1678
1698
|
const bestSources = bestScore ? scoredSources.filter((item) => item.score === bestScore) : [];
|
|
1679
1699
|
if (bestSources.length === 1) {
|
|
@@ -1856,9 +1876,11 @@ function normalizeInjectableCssForTargetWithImports(css, file) {
|
|
|
1856
1876
|
};
|
|
1857
1877
|
try {
|
|
1858
1878
|
const root = postcss.parse(css);
|
|
1879
|
+
const changed = isMiniProgramStyleOutputFile(file) ? removeUnsupportedMiniProgramCssImportsRoot(root) : false;
|
|
1880
|
+
const importedStyleFiles = collectImportedStyleFilesRoot(root, file);
|
|
1859
1881
|
return {
|
|
1860
|
-
css:
|
|
1861
|
-
importedStyleFiles:
|
|
1882
|
+
css: changed ? root.toString() : css,
|
|
1883
|
+
importedStyleFiles: importedStyleFiles.size > 0 ? importedStyleFiles : collectImportedStyleFilesFallback(css, file)
|
|
1862
1884
|
};
|
|
1863
1885
|
} catch {
|
|
1864
1886
|
const fallbackCss = removeUnsupportedMiniProgramCssImportsFallback(css, file);
|
|
@@ -1892,12 +1914,16 @@ function collectImportedStyleFilesFromRequests(requests, targetFile) {
|
|
|
1892
1914
|
function collectImportedStyleFilesRoot(root, targetFile) {
|
|
1893
1915
|
return collectImportedStyleFilesFromRequests(collectCssImportRequestsRoot(root), targetFile);
|
|
1894
1916
|
}
|
|
1917
|
+
function collectImportedStyleFilesFallback(css, targetFile) {
|
|
1918
|
+
return collectImportedStyleFilesFromRequests([...css.matchAll(/@import\s+(?:url\(\s*)?(?:"([^"]+)"|'([^']+)'|([^\s;)]+))/g)].map((match) => match[1] ?? match[2] ?? match[3]).filter((request) => typeof request === "string" && request.length > 0), targetFile);
|
|
1919
|
+
}
|
|
1895
1920
|
function collectImportedStyleFiles(css, targetFile) {
|
|
1896
1921
|
if (!css.includes("@import")) return /* @__PURE__ */ new Set();
|
|
1897
1922
|
try {
|
|
1898
|
-
|
|
1923
|
+
const imports = collectImportedStyleFilesRoot(postcss.parse(css), targetFile);
|
|
1924
|
+
return imports.size > 0 ? imports : collectImportedStyleFilesFallback(css, targetFile);
|
|
1899
1925
|
} catch {}
|
|
1900
|
-
return
|
|
1926
|
+
return collectImportedStyleFilesFallback(css, targetFile);
|
|
1901
1927
|
}
|
|
1902
1928
|
function normalizeMarkerOutputFile(markerFile, resolveViteProcessedCssOutputFile) {
|
|
1903
1929
|
return resolveViteProcessedCssOutputFile?.(markerFile) ?? markerFile;
|
|
@@ -2054,9 +2080,21 @@ function isUnscopedMiniProgramTailwindPreflightRule(rule) {
|
|
|
2054
2080
|
const declarations = rule.nodes?.filter((node) => node.type === "decl") ?? [];
|
|
2055
2081
|
return declarations.length > 0 && declarations.every(isMiniProgramTailwindPreflightDeclaration);
|
|
2056
2082
|
}
|
|
2083
|
+
function isScopedMiniProgramTailwindContentInitRule(rule) {
|
|
2084
|
+
const selectors = rule.selectors ?? [rule.selector];
|
|
2085
|
+
if (selectors.length === 0 || !selectors.every((selector) => {
|
|
2086
|
+
const normalized = normalizeCssSignatureValue(selector);
|
|
2087
|
+
return hasVueScopedAttr(selector) && MINI_PROGRAM_PREFLIGHT_SELECTORS.has(normalized);
|
|
2088
|
+
})) return false;
|
|
2089
|
+
const declarations = rule.nodes?.filter((node) => node.type === "decl") ?? [];
|
|
2090
|
+
return declarations.length > 0 && declarations.every((decl) => decl.prop === "--tw-content");
|
|
2091
|
+
}
|
|
2057
2092
|
function hasUnscopedMiniProgramTailwindPreflightRule(css) {
|
|
2058
2093
|
return /(?:^|[{}])\s*view\s*,\s*text\s*,\s*::after\s*,\s*::before\s*\{/.test(css);
|
|
2059
2094
|
}
|
|
2095
|
+
function hasScopedMiniProgramTailwindContentInitRule(css) {
|
|
2096
|
+
return /(?:^|[{}])[^{}]*\.data-v-[\w-][^{}]*\{\s*--tw-content\s*:/.test(css);
|
|
2097
|
+
}
|
|
2060
2098
|
function collectRootScopedComparableCssCoverage(cssSources) {
|
|
2061
2099
|
const rules = /* @__PURE__ */ new Set();
|
|
2062
2100
|
const atRules = /* @__PURE__ */ new Set();
|
|
@@ -2093,14 +2131,15 @@ function isRuleCoveredByRootCss(rule, coverage) {
|
|
|
2093
2131
|
return declarationKeys.length > 0 && selectors.every((selector) => {
|
|
2094
2132
|
const rootDeclarations = coverage.declarationsBySelector.get(normalizeCssSignatureValue(selector));
|
|
2095
2133
|
return rootDeclarations != null && declarationKeys.every((declaration) => rootDeclarations.has(declaration));
|
|
2096
|
-
})
|
|
2134
|
+
});
|
|
2097
2135
|
}
|
|
2098
2136
|
function removeScopedCssCoveredByRootStyleSources(css, rootSources) {
|
|
2099
2137
|
if (!hasVueScopedAttr(css)) return css;
|
|
2100
2138
|
const hasScopedTailwindGeneratedCss = /tailwindcss v\d/i.test(css);
|
|
2101
2139
|
const hasUnscopedMiniProgramPreflight = hasUnscopedMiniProgramTailwindPreflightRule(css);
|
|
2140
|
+
const hasScopedMiniProgramContentInit = hasScopedMiniProgramTailwindContentInitRule(css);
|
|
2102
2141
|
const coverage = collectRootScopedComparableCssCoverage(rootSources);
|
|
2103
|
-
if (coverage.rules.size === 0 && coverage.atRules.size === 0 && !hasScopedTailwindGeneratedCss && !hasUnscopedMiniProgramPreflight) return css;
|
|
2142
|
+
if (coverage.rules.size === 0 && coverage.atRules.size === 0 && !hasScopedTailwindGeneratedCss && !hasUnscopedMiniProgramPreflight && !hasScopedMiniProgramContentInit) return css;
|
|
2104
2143
|
try {
|
|
2105
2144
|
const root = postcss.parse(css);
|
|
2106
2145
|
let changed = false;
|
|
@@ -2111,7 +2150,7 @@ function removeScopedCssCoveredByRootStyleSources(css, rootSources) {
|
|
|
2111
2150
|
}
|
|
2112
2151
|
});
|
|
2113
2152
|
root.walkRules((rule) => {
|
|
2114
|
-
if (isRuleCoveredByRootCss(rule, coverage) || hasScopedTailwindGeneratedCss && isLikelyTailwindGlobalRule(rule) || isUnscopedMiniProgramTailwindPreflightRule(rule)) {
|
|
2153
|
+
if (isRuleCoveredByRootCss(rule, coverage) || hasScopedTailwindGeneratedCss && isLikelyTailwindGlobalRule(rule) || isUnscopedMiniProgramTailwindPreflightRule(rule) || isScopedMiniProgramTailwindContentInitRule(rule)) {
|
|
2115
2154
|
rule.remove();
|
|
2116
2155
|
changed = true;
|
|
2117
2156
|
}
|
|
@@ -2245,6 +2284,7 @@ function shouldUseCssAssetAsMainInjectionTarget(opts, file, records, options, bu
|
|
|
2245
2284
|
}) === true && !isMiniProgramStyleOutputFile(file) && matchedRootWebOutputTargets.length > 0) return matchedRootWebOutputTargets.includes(fileKey);
|
|
2246
2285
|
const explicitRootTargets = records.filter((record) => record.injectIntoMain === true).map((record) => typeof record.outputFile === "string" ? normalizeOutputPathKey(record.outputFile) : void 0).filter((outputFile) => typeof outputFile === "string" && isRootStyleOutputFile(outputFile) && !isMiniProgramStyleOutputFile(outputFile));
|
|
2247
2286
|
const explicitWebCssTargets = records.filter((record) => record.injectIntoMain === true).map((record) => typeof record.outputFile === "string" ? normalizeOutputPathKey(record.outputFile) : void 0).filter((outputFile) => typeof outputFile === "string" && isCssOutputFile(outputFile) && !isMiniProgramStyleOutputFile(outputFile));
|
|
2287
|
+
const explicitStyleOutputTargets = records.filter((record) => record.injectIntoMain === true).map((record) => typeof record.outputFile === "string" ? normalizeOutputPathKey(record.outputFile) : void 0).filter((outputFile) => typeof outputFile === "string" && isRootStyleOutputFile(outputFile));
|
|
2248
2288
|
if (context !== void 0 && options.cssPipelineStrategy?.shouldPreferExplicitWebCssTargets?.({
|
|
2249
2289
|
...context,
|
|
2250
2290
|
explicitRootTargets,
|
|
@@ -2254,12 +2294,25 @@ function shouldUseCssAssetAsMainInjectionTarget(opts, file, records, options, bu
|
|
|
2254
2294
|
if (explicitRootTargets.length > 0) return explicitRootTargets.includes(fileKey);
|
|
2255
2295
|
if (records.some((record) => {
|
|
2256
2296
|
if (record.injectIntoMain !== true) return false;
|
|
2297
|
+
if (explicitStyleOutputTargets.length > 0) return explicitStyleOutputTargets.includes(fileKey) || isRootStyleOutputFile(file) && isViteProcessedRootStyleImportingTargets(bundle, file, explicitStyleOutputTargets) || isRootStyleOutputFile(file) && opts.mainCssChunkMatcher(file, opts.appType) && explicitStyleOutputTargets.some((outputFile) => opts.mainCssChunkMatcher(outputFile, opts.appType));
|
|
2257
2298
|
return isRootStyleOutputFile(file) || typeof record.outputFile === "string" && normalizeOutputPathKey(record.outputFile) === fileKey;
|
|
2258
2299
|
})) return true;
|
|
2259
|
-
if (records.some((record) => record.injectIntoMain === true))
|
|
2300
|
+
if (records.some((record) => record.injectIntoMain === true)) {
|
|
2301
|
+
const matchedExplicitMiniProgramTargets = explicitStyleOutputTargets.filter((outputFile) => isMiniProgramStyleOutputFile(outputFile) && opts.mainCssChunkMatcher(outputFile, opts.appType));
|
|
2302
|
+
if (matchedExplicitMiniProgramTargets.length > 0) return matchedExplicitMiniProgramTargets.includes(fileKey);
|
|
2303
|
+
return isRootStyleOutputFile(file) && isMiniProgramStyleOutputFile(file);
|
|
2304
|
+
}
|
|
2260
2305
|
if (opts.mainCssChunkMatcher(file, opts.appType)) return true;
|
|
2261
2306
|
return isRootStyleOutputFile(file) && records.some((record) => record.injectIntoMain === true);
|
|
2262
2307
|
}
|
|
2308
|
+
function isViteProcessedRootStyleImportingTargets(bundle, file, targetFiles) {
|
|
2309
|
+
const targetFileSet = new Set(targetFiles.map(normalizeOutputPathKey));
|
|
2310
|
+
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
2311
|
+
if (output.type !== "asset" || normalizeOutputPathKey(getAssetFile$1(bundleFile, output)) !== normalizeOutputPathKey(file)) continue;
|
|
2312
|
+
return [...collectImportedStyleFiles(readAssetSource$2(output), file)].some((importedFile) => targetFileSet.has(normalizeOutputPathKey(importedFile)));
|
|
2313
|
+
}
|
|
2314
|
+
return false;
|
|
2315
|
+
}
|
|
2263
2316
|
function isViteProcessedCssResultImported(record, importedStyleFiles) {
|
|
2264
2317
|
return importedStyleFiles.has(normalizeOutputPathKey(record.file)) || typeof record.outputFile === "string" && importedStyleFiles.has(normalizeOutputPathKey(record.outputFile));
|
|
2265
2318
|
}
|
|
@@ -2303,7 +2356,84 @@ function removeCssCoveredByImportedViteResults(css, importedCssSources) {
|
|
|
2303
2356
|
if (importedCssSources.length === 0) return css;
|
|
2304
2357
|
const importedCss = importedCssSources.map((source) => stripBundlerGeneratedCssMarkers(source).trim()).filter(Boolean).join("\n");
|
|
2305
2358
|
if (importedCss.length === 0) return css;
|
|
2306
|
-
return
|
|
2359
|
+
return restoreCssImportAtRules(css, removeCssRulesCoveredBySources(css, [importedCss], { exactOnly: true }));
|
|
2360
|
+
}
|
|
2361
|
+
function removeCssRulesCoveredBySources(css, sources, options = {}) {
|
|
2362
|
+
if (sources.length === 0 || css.trim().length === 0) return css;
|
|
2363
|
+
const coverage = collectRootScopedComparableCssCoverage(sources);
|
|
2364
|
+
const coveredRuleCss = collectNormalizedRuleCss(sources);
|
|
2365
|
+
if (coverage.rules.size === 0 && coverage.declarationsBySelector.size === 0 && coveredRuleCss.size === 0) return css;
|
|
2366
|
+
try {
|
|
2367
|
+
const root = postcss.parse(css);
|
|
2368
|
+
let changed = false;
|
|
2369
|
+
root.walkRules((rule) => {
|
|
2370
|
+
if (!coveredRuleCss.has(normalizeCssSignatureValue(rule.toString())) && (options.exactOnly === true || !isRuleCoveredByRootCss(rule, coverage))) return;
|
|
2371
|
+
rule.remove();
|
|
2372
|
+
changed = true;
|
|
2373
|
+
});
|
|
2374
|
+
return changed ? root.toString() : css;
|
|
2375
|
+
} catch {
|
|
2376
|
+
return css;
|
|
2377
|
+
}
|
|
2378
|
+
}
|
|
2379
|
+
function collectNormalizedRuleCss(sources) {
|
|
2380
|
+
const rules = /* @__PURE__ */ new Set();
|
|
2381
|
+
for (const source of sources) try {
|
|
2382
|
+
postcss.parse(source).walkRules((rule) => {
|
|
2383
|
+
rules.add(normalizeCssSignatureValue(rule.toString()));
|
|
2384
|
+
});
|
|
2385
|
+
} catch {}
|
|
2386
|
+
return rules;
|
|
2387
|
+
}
|
|
2388
|
+
function collectCssImportAtRuleCss(css) {
|
|
2389
|
+
if (!css.includes("@import")) return [];
|
|
2390
|
+
const fallbackImports = [...css.matchAll(/@import\s[^;]+;?/g)].map((match) => match[0]);
|
|
2391
|
+
if (fallbackImports.length > 0) return fallbackImports;
|
|
2392
|
+
try {
|
|
2393
|
+
const root = postcss.parse(css);
|
|
2394
|
+
const imports = [];
|
|
2395
|
+
root.each((node) => {
|
|
2396
|
+
if (node.type === "atrule" && node.name === "import") imports.push(node.toString());
|
|
2397
|
+
});
|
|
2398
|
+
return imports;
|
|
2399
|
+
} catch {
|
|
2400
|
+
return [];
|
|
2401
|
+
}
|
|
2402
|
+
}
|
|
2403
|
+
function parseCssImportRequest(importCss) {
|
|
2404
|
+
const trimmed = importCss.trim();
|
|
2405
|
+
if (!trimmed.startsWith("@import")) return;
|
|
2406
|
+
return parseTailwindCssDirectiveRequest(trimmed.slice(7).trim().replace(/;$/, "").trim());
|
|
2407
|
+
}
|
|
2408
|
+
function shouldRestoreCssImportAtRule(importCss, file) {
|
|
2409
|
+
if (file === void 0 || !isMiniProgramStyleOutputFile(file)) return true;
|
|
2410
|
+
const request = parseCssImportRequest(importCss);
|
|
2411
|
+
if (request === void 0) return false;
|
|
2412
|
+
if (isMiniProgramLocalCssImportRequest(request)) return true;
|
|
2413
|
+
return isStyleImportRequest(request) && !request.includes("/");
|
|
2414
|
+
}
|
|
2415
|
+
function restoreCssImportAtRules(source, filtered, file) {
|
|
2416
|
+
const imports = collectCssImportAtRuleCss(source).filter((importCss) => shouldRestoreCssImportAtRule(importCss, file));
|
|
2417
|
+
if (imports.length === 0) return filtered;
|
|
2418
|
+
const missingImports = imports.filter((importCss) => !filtered.includes(importCss));
|
|
2419
|
+
if (missingImports.length === 0) return filtered;
|
|
2420
|
+
return appendCss$1(missingImports.join("\n"), filtered);
|
|
2421
|
+
}
|
|
2422
|
+
function removeCommentOnlyAtRules(css) {
|
|
2423
|
+
if (!css.includes("@")) return css;
|
|
2424
|
+
try {
|
|
2425
|
+
const root = postcss.parse(css);
|
|
2426
|
+
let changed = false;
|
|
2427
|
+
root.walkAtRules((atRule) => {
|
|
2428
|
+
if (!atRule.nodes || atRule.nodes.length === 0) return;
|
|
2429
|
+
if (atRule.nodes.some((node) => node.type !== "comment")) return;
|
|
2430
|
+
atRule.remove();
|
|
2431
|
+
changed = true;
|
|
2432
|
+
});
|
|
2433
|
+
return changed ? root.toString() : css;
|
|
2434
|
+
} catch {
|
|
2435
|
+
return css;
|
|
2436
|
+
}
|
|
2307
2437
|
}
|
|
2308
2438
|
function collectImportedBundleCssSources(bundle, importedStyleFiles) {
|
|
2309
2439
|
if (importedStyleFiles.size === 0) return [];
|
|
@@ -2569,7 +2699,9 @@ function injectViteProcessedCssIntoMainCssAssets(bundle, options) {
|
|
|
2569
2699
|
if (missingCss.length === 0 || !hasNonCommentCss(missingCss) || containsCssAfterMinify(nextCss, missingCss)) continue;
|
|
2570
2700
|
nextCss = appendCss$1(nextCss, missingCss);
|
|
2571
2701
|
}
|
|
2572
|
-
|
|
2702
|
+
const finalImportedCssSources = collectImportedBundleCssSources(bundle, collectImportedStyleFiles(originalSource, file));
|
|
2703
|
+
nextCss = transformCss(removeCommentOnlyAtRules(restoreCssImportAtRules(originalSource, removeCssRulesCoveredBySources(nextCss, finalImportedCssSources, { exactOnly: true }).trim(), file)), file);
|
|
2704
|
+
if (nextCss.trim() === originalSource.trim()) nextCss = originalSource;
|
|
2573
2705
|
if (nextCss !== originalSource) {
|
|
2574
2706
|
output.source = nextCss;
|
|
2575
2707
|
options.markCssAssetProcessed?.(output, file);
|
|
@@ -2854,14 +2986,15 @@ function getAssetFile(bundleFile, asset) {
|
|
|
2854
2986
|
return asset.fileName || bundleFile;
|
|
2855
2987
|
}
|
|
2856
2988
|
function finalizeWebviewCssCompat(bundle, options) {
|
|
2857
|
-
|
|
2989
|
+
const generatorOptions = normalizeWeappTailwindcssGeneratorOptions(options.opts.generator);
|
|
2990
|
+
if (generatorOptions.webCompat === false) return 0;
|
|
2858
2991
|
let transformed = 0;
|
|
2859
2992
|
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
2860
2993
|
if (output.type !== "asset") continue;
|
|
2861
2994
|
const file = getAssetFile(bundleFile, output);
|
|
2862
2995
|
if (!options.opts.cssMatcher(file) || !/\.css(?:$|[?#])/i.test(file)) continue;
|
|
2863
2996
|
const rawSource = readAssetSource(output);
|
|
2864
|
-
const nextCss = transformWebCssSafeSelectors(transformWebCssCompat(rawSource,
|
|
2997
|
+
const nextCss = transformWebCssSafeSelectors(transformWebCssCompat(rawSource, generatorOptions.webCompat ?? true), { escapeMap: options.opts.escapeMap });
|
|
2865
2998
|
if (nextCss === rawSource) continue;
|
|
2866
2999
|
output.source = nextCss;
|
|
2867
3000
|
options.recordCssAssetResult?.(file, nextCss);
|
|
@@ -3321,7 +3454,7 @@ function resolveUniAppXStyleIsolationEnabled(root) {
|
|
|
3321
3454
|
//#region src/uni-app-x/vite.ts
|
|
3322
3455
|
let transformUVuePromise;
|
|
3323
3456
|
function loadTransformUVue() {
|
|
3324
|
-
transformUVuePromise ?? (transformUVuePromise = import("./transform-
|
|
3457
|
+
transformUVuePromise ?? (transformUVuePromise = import("./transform-BgnNYkIG.mjs").then((mod) => mod.transformUVue));
|
|
3325
3458
|
return transformUVuePromise;
|
|
3326
3459
|
}
|
|
3327
3460
|
const preprocessorLangs = /* @__PURE__ */ new Set([
|
|
@@ -3779,7 +3912,7 @@ function collectRememberedCssReplayGroups(sources, opts, rootDir, isWebGenerator
|
|
|
3779
3912
|
//#endregion
|
|
3780
3913
|
//#region src/bundlers/vite/generate-bundle/remembered-css-replay.ts
|
|
3781
3914
|
async function processRememberedCssReplay(options) {
|
|
3782
|
-
const { addWatchFile, activeViteCssCacheFiles, bundleFiles, cache, createScopedGeneratorRuntime, createScopedSourceCandidateGetter, createScopedSourceCandidateSourceGetter, cssTaskFactories, debug, defaultStyleOutputExtension, emitOrReplayCssAsset, generatorRuntime, generatorPlatform, getCssHandlerOptions, getCssUserHandlerOptions, getRememberedCssSignature, getRememberedCssSources, isNativeAppStyleTarget, isWebGeneratorTarget, lastCssResultByFile, lastCssSourceHashByFile, markCssAssetProcessed, metrics, normalizeViteCssCacheKey, onUpdate, opts, recordCssAssetResult, recordViteProcessedCssAssetResult, refreshRememberedCssSource, rootDir, runtimeState, setRememberedCssSignature, shouldInjectCssIntoMainFromOutput, shouldPreserveAppCssExtension, sourceRoot, styleHandler, timeTask, useIncrementalMode } = options;
|
|
3915
|
+
const { addWatchFile, activeViteCssCacheFiles, bundleFiles, cache, changedCssFiles = /* @__PURE__ */ new Set(), createScopedGeneratorRuntime, createScopedSourceCandidateGetter, createScopedSourceCandidateSourceGetter, cssTaskFactories, 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;
|
|
3783
3916
|
const rememberedReplayGroups = collectRememberedCssReplayGroups(getRememberedCssSources?.(), opts, rootDir, isWebGeneratorTarget, shouldPreserveAppCssExtension, sourceRoot, defaultStyleOutputExtension, bundleFiles);
|
|
3784
3917
|
for (const [outputFile, rememberedGroup] of rememberedReplayGroups) {
|
|
3785
3918
|
if (isHTMLRequest(outputFile) || options.opts.htmlMatcher(outputFile)) continue;
|
|
@@ -3791,6 +3924,7 @@ async function processRememberedCssReplay(options) {
|
|
|
3791
3924
|
const rememberedCssSource = mergeRememberedCssSources(refreshedRememberedGroup.map((item) => item.remembered), outputFile);
|
|
3792
3925
|
if (!rememberedCssSource) continue;
|
|
3793
3926
|
const { rawSource, sourceFile } = rememberedCssSource;
|
|
3927
|
+
const generatorRawSource = isWebGeneratorTarget ? rawSource : normalizeMiniProgramGeneratorCssSource(rawSource, outputFile);
|
|
3794
3928
|
activeViteCssCacheFiles.add(normalizeViteCssCacheKey(outputFile));
|
|
3795
3929
|
activeViteCssCacheFiles.add(normalizeViteCssCacheKey(sourceFile));
|
|
3796
3930
|
const outputCssHandlerOptions = getCssHandlerOptions(outputFile);
|
|
@@ -3800,17 +3934,21 @@ async function processRememberedCssReplay(options) {
|
|
|
3800
3934
|
};
|
|
3801
3935
|
const scopedSourceCandidateGetter = createScopedSourceCandidateGetter(outputFile, cssHandlerOptions);
|
|
3802
3936
|
const scopedSourceCandidateSourceGetter = createScopedSourceCandidateSourceGetter(outputFile, cssHandlerOptions);
|
|
3803
|
-
const scopedGeneratorRuntime = await createScopedGeneratorRuntime(outputFile, cssHandlerOptions, generatorRuntime,
|
|
3804
|
-
const cssRuntimeSignature = createCssRuntimeSignature(createCandidateSignature(scopedGeneratorRuntime), await createScopedGeneratorCandidateSignature(
|
|
3937
|
+
const scopedGeneratorRuntime = await createScopedGeneratorRuntime(outputFile, cssHandlerOptions, generatorRuntime, generatorRawSource, sourceFile);
|
|
3938
|
+
const cssRuntimeSignature = createCssRuntimeSignature(createCandidateSignature(scopedGeneratorRuntime), await createScopedGeneratorCandidateSignature(generatorRawSource, sourceFile, createCandidateSignature(scopedGeneratorRuntime), scopedSourceCandidateGetter, {
|
|
3805
3939
|
includeFallbackSignature: cssHandlerOptions.isMainChunk,
|
|
3806
3940
|
majorVersion: runtimeState.tailwindRuntime.majorVersion
|
|
3807
3941
|
}));
|
|
3808
3942
|
const cssRuntimeAffectingHash = cache.computeHash(createRuntimeAffectingSourceSignature(rawSource, "css"));
|
|
3809
3943
|
const rememberedCssRuntimeSignature = createRememberedCssRuntimeSignature(cssRuntimeSignature, cssRuntimeAffectingHash);
|
|
3810
|
-
const
|
|
3944
|
+
const rawSourceHash = cache.computeHash(rawSource);
|
|
3945
|
+
const previousRawSourceHash = lastCssRawSourceHashByFile.get(outputFile);
|
|
3946
|
+
const cssSourceChanged = changedCssFiles.has(outputFile) || changedCssFiles.has(sourceFile) || previousRawSourceHash != null && previousRawSourceHash !== rawSourceHash;
|
|
3947
|
+
const previousCss = useIncrementalMode && !cssSourceChanged && getLastCssSourceHash(lastCssSourceHashByFile, outputFile) === cssRuntimeAffectingHash ? getLastCssResult(lastCssResultByFile, outputFile) : void 0;
|
|
3811
3948
|
const allRememberedSignaturesFresh = rememberedKeys.length > 0 && rememberedKeys.every((key) => getRememberedCssSignature?.(key) === rememberedCssRuntimeSignature);
|
|
3812
3949
|
if (bundleFiles.includes(outputFile) || bundleFiles.includes(sourceFile) || allRememberedSignaturesFresh) continue;
|
|
3813
|
-
const
|
|
3950
|
+
const sourceTraceSources = scopedSourceCandidateSourceGetter ? await createScopedGeneratorSourceTraceMap(generatorRawSource, sourceFile, scopedSourceCandidateSourceGetter) : void 0;
|
|
3951
|
+
const sourceTraceTokenSources = sourceTraceSources ? createCssTokenSourceMap(sourceTraceSources, opts) : void 0;
|
|
3814
3952
|
const annotateCss = (css) => annotateCssSourceTrace(css, {
|
|
3815
3953
|
opts,
|
|
3816
3954
|
tokenSources: sourceTraceTokenSources
|
|
@@ -3818,13 +3956,32 @@ async function processRememberedCssReplay(options) {
|
|
|
3818
3956
|
const shouldRecordRememberedReplayCss = useIncrementalMode || isNativeAppStyleTarget;
|
|
3819
3957
|
const shouldEmitRememberedReplayCssAsset = shouldRecordRememberedReplayCss;
|
|
3820
3958
|
if (!shouldRecordRememberedReplayCss) continue;
|
|
3959
|
+
if (!isWebGeneratorTarget && isPureLocalCssImportWrapper(rawSource)) {
|
|
3960
|
+
cssTaskFactories.push(() => timeTask("css.replay", async () => {
|
|
3961
|
+
const start = performance.now();
|
|
3962
|
+
const css = annotateCss(normalizeMiniProgramImportShell(rawSource));
|
|
3963
|
+
lastCssRawSourceHashByFile.set(outputFile, rawSourceHash);
|
|
3964
|
+
rememberLastCssResult(lastCssResultByFile, lastCssSourceHashByFile, outputFile, css, cssRuntimeAffectingHash);
|
|
3965
|
+
for (const key of rememberedKeys) setRememberedCssSignature?.(key, rememberedCssRuntimeSignature);
|
|
3966
|
+
recordCssAssetResult?.(outputFile, css);
|
|
3967
|
+
if (shouldEmitRememberedReplayCssAsset) {
|
|
3968
|
+
const replayAsset = emitOrReplayCssAsset(outputFile, css);
|
|
3969
|
+
if (replayAsset) markCssAssetProcessed?.(replayAsset, outputFile);
|
|
3970
|
+
}
|
|
3971
|
+
metrics.css.elapsed += measureElapsed(start);
|
|
3972
|
+
metrics.css.transformed++;
|
|
3973
|
+
onUpdate(outputFile, rawSource, css);
|
|
3974
|
+
debug("css replay preserve local import shell: %s", outputFile);
|
|
3975
|
+
}));
|
|
3976
|
+
continue;
|
|
3977
|
+
}
|
|
3821
3978
|
cssTaskFactories.push(() => timeTask("css.replay", async () => {
|
|
3822
3979
|
const start = performance.now();
|
|
3823
3980
|
const generated = await generateTailwindV4Css({
|
|
3824
3981
|
opts,
|
|
3825
3982
|
runtimeState,
|
|
3826
3983
|
runtime: scopedGeneratorRuntime,
|
|
3827
|
-
rawSource,
|
|
3984
|
+
rawSource: generatorRawSource,
|
|
3828
3985
|
file: sourceFile,
|
|
3829
3986
|
outputFile,
|
|
3830
3987
|
cssHandlerOptions,
|
|
@@ -3835,7 +3992,8 @@ async function processRememberedCssReplay(options) {
|
|
|
3835
3992
|
debug,
|
|
3836
3993
|
previousCss
|
|
3837
3994
|
});
|
|
3838
|
-
const css = annotateCss(generated?.css ?? (await styleHandler(
|
|
3995
|
+
const css = annotateCss(generated?.css ?? (await styleHandler(generatorRawSource, cssHandlerOptions)).css);
|
|
3996
|
+
lastCssRawSourceHashByFile.set(outputFile, rawSourceHash);
|
|
3839
3997
|
rememberLastCssResult(lastCssResultByFile, lastCssSourceHashByFile, outputFile, css, cssRuntimeAffectingHash);
|
|
3840
3998
|
for (const key of rememberedKeys) setRememberedCssSignature?.(key, rememberedCssRuntimeSignature);
|
|
3841
3999
|
if (generated) {
|
|
@@ -3846,6 +4004,10 @@ async function processRememberedCssReplay(options) {
|
|
|
3846
4004
|
injectIntoMain: outputCssHandlerOptions.isMainChunk ? false : shouldInjectReplayCssIntoMain,
|
|
3847
4005
|
outputFile
|
|
3848
4006
|
});
|
|
4007
|
+
if (outputFile !== sourceFile) recordViteProcessedCssAssetResult?.(outputFile, css, {
|
|
4008
|
+
injectIntoMain: outputCssHandlerOptions.isMainChunk ? false : shouldInjectReplayCssIntoMain,
|
|
4009
|
+
outputFile
|
|
4010
|
+
});
|
|
3849
4011
|
debug("css replay generated result: %s bytes=%d", outputFile, css.length);
|
|
3850
4012
|
}
|
|
3851
4013
|
if (shouldEmitRememberedReplayCssAsset) {
|
|
@@ -4104,37 +4266,119 @@ function createStableTextSignature(input) {
|
|
|
4104
4266
|
}
|
|
4105
4267
|
return (hash >>> 0).toString(36);
|
|
4106
4268
|
}
|
|
4269
|
+
function parseQuotedRequest(params) {
|
|
4270
|
+
const input = params.trim();
|
|
4271
|
+
const quote = input[0];
|
|
4272
|
+
if (quote !== "\"" && quote !== "'") return;
|
|
4273
|
+
let escaped = false;
|
|
4274
|
+
for (let index = 1; index < input.length; index++) {
|
|
4275
|
+
const char = input[index];
|
|
4276
|
+
if (escaped) {
|
|
4277
|
+
escaped = false;
|
|
4278
|
+
continue;
|
|
4279
|
+
}
|
|
4280
|
+
if (char === "\\") {
|
|
4281
|
+
escaped = true;
|
|
4282
|
+
continue;
|
|
4283
|
+
}
|
|
4284
|
+
if (char === quote) return input.slice(1, index);
|
|
4285
|
+
}
|
|
4286
|
+
}
|
|
4287
|
+
function parseSourceParams(params) {
|
|
4288
|
+
let input = params.trim();
|
|
4289
|
+
let negated = false;
|
|
4290
|
+
if (input.startsWith("not ")) {
|
|
4291
|
+
negated = true;
|
|
4292
|
+
input = input.slice(4).trim();
|
|
4293
|
+
}
|
|
4294
|
+
if (input.startsWith("inline(") && input.endsWith(")")) return {
|
|
4295
|
+
prefix: negated ? "source:inline:not" : "source:inline",
|
|
4296
|
+
value: input.slice(7, -1).trim()
|
|
4297
|
+
};
|
|
4298
|
+
const request = parseQuotedRequest(input);
|
|
4299
|
+
if (!request) return;
|
|
4300
|
+
return {
|
|
4301
|
+
prefix: negated ? "source:not" : "source",
|
|
4302
|
+
value: request
|
|
4303
|
+
};
|
|
4304
|
+
}
|
|
4305
|
+
function parseTailwindImportSource(params) {
|
|
4306
|
+
if (parseQuotedRequest(params) !== "tailwindcss") return;
|
|
4307
|
+
return /\bsource\(([^)]*)\)/.exec(params)?.[1]?.trim();
|
|
4308
|
+
}
|
|
4309
|
+
function hasExplicitTailwindV4Directive(source) {
|
|
4310
|
+
try {
|
|
4311
|
+
let found = false;
|
|
4312
|
+
postcss.parse(source).walkAtRules((rule) => {
|
|
4313
|
+
if (rule.name === "config" || rule.name === "source" || rule.name === "plugin" || rule.name === "custom-variant" || rule.name === "theme" || rule.name === "utility" || rule.name === "variant" || rule.name === "apply") {
|
|
4314
|
+
found = true;
|
|
4315
|
+
return false;
|
|
4316
|
+
}
|
|
4317
|
+
});
|
|
4318
|
+
return found;
|
|
4319
|
+
} catch {
|
|
4320
|
+
return false;
|
|
4321
|
+
}
|
|
4322
|
+
}
|
|
4107
4323
|
function collectTailwindV4SourceFingerprint(source) {
|
|
4108
4324
|
const tokens = /* @__PURE__ */ new Set();
|
|
4109
4325
|
const add = (prefix, value) => {
|
|
4110
4326
|
tokens.add(`${prefix}:${value.trim()}`);
|
|
4111
4327
|
};
|
|
4112
|
-
for (const match of source.matchAll(/@config\s+(["'])(.+?)\1\s*;?/g)) {
|
|
4113
|
-
const configRequest = match[2];
|
|
4114
|
-
add("config", path.basename(configRequest));
|
|
4115
|
-
add("config-request", configRequest.replace(/\\/g, "/"));
|
|
4116
|
-
}
|
|
4117
|
-
for (const match of source.matchAll(/@source\s+(not\s+)?(["'])(.+?)\2\s*;?/g)) add(match[1] ? "source:not" : "source", match[3]);
|
|
4118
|
-
for (const match of source.matchAll(/@plugin\s+(["'])(.+?)\1\s*(?:\{([\s\S]*?)\}|;)/g)) {
|
|
4119
|
-
const request = match[2];
|
|
4120
|
-
const optionBlock = match[3];
|
|
4121
|
-
add("plugin", request);
|
|
4122
|
-
add("plugin-request", request.replace(/\\/g, "/"));
|
|
4123
|
-
if (optionBlock !== void 0) add("plugin-options", `${request}:${createStableTextSignature(optionBlock)}`);
|
|
4124
|
-
}
|
|
4125
4328
|
try {
|
|
4126
|
-
postcss.parse(source)
|
|
4127
|
-
|
|
4128
|
-
if (
|
|
4129
|
-
|
|
4130
|
-
add("
|
|
4131
|
-
|
|
4329
|
+
const root = postcss.parse(source);
|
|
4330
|
+
root.walkAtRules((rule) => {
|
|
4331
|
+
if (rule.name === "import") {
|
|
4332
|
+
const sourceMode = parseTailwindImportSource(rule.params);
|
|
4333
|
+
if (sourceMode) add("import-source", sourceMode);
|
|
4334
|
+
return;
|
|
4335
|
+
}
|
|
4336
|
+
if (rule.name === "config") {
|
|
4337
|
+
const configRequest = parseQuotedRequest(rule.params);
|
|
4338
|
+
if (configRequest) {
|
|
4339
|
+
add("config", path.basename(configRequest));
|
|
4340
|
+
add("config-request", configRequest.replace(/\\/g, "/"));
|
|
4341
|
+
}
|
|
4342
|
+
return;
|
|
4343
|
+
}
|
|
4344
|
+
if (rule.name === "source") {
|
|
4345
|
+
const parsed = parseSourceParams(rule.params);
|
|
4346
|
+
if (parsed) add(parsed.prefix, parsed.value);
|
|
4347
|
+
return;
|
|
4348
|
+
}
|
|
4349
|
+
if (rule.name === "plugin") {
|
|
4350
|
+
const request = parseQuotedRequest(rule.params);
|
|
4351
|
+
if (!request) return;
|
|
4352
|
+
add("plugin", request);
|
|
4353
|
+
add("plugin-request", request.replace(/\\/g, "/"));
|
|
4354
|
+
if (rule.nodes?.length) {
|
|
4355
|
+
add("plugin-options", `${request}:${createStableTextSignature(rule.toString())}`);
|
|
4356
|
+
rule.walkDecls((decl) => {
|
|
4357
|
+
add("plugin-option", `${request}:${decl.prop}:${decl.value}`);
|
|
4358
|
+
});
|
|
4359
|
+
}
|
|
4360
|
+
return;
|
|
4361
|
+
}
|
|
4362
|
+
if (rule.name === "custom-variant") {
|
|
4363
|
+
const [name] = rule.params.trim().split(/\s+/, 1);
|
|
4364
|
+
if (name) add("custom-variant", name);
|
|
4365
|
+
return;
|
|
4366
|
+
}
|
|
4367
|
+
if (rule.name === "theme" || rule.name === "utility" || rule.name === "variant" || rule.name === "layer") {
|
|
4368
|
+
const [name] = rule.params.trim().split(/\s+/, 1);
|
|
4369
|
+
if (name) add("directive", name);
|
|
4370
|
+
}
|
|
4371
|
+
});
|
|
4372
|
+
root.walkDecls((decl) => {
|
|
4373
|
+
if (decl.prop.startsWith("--")) add("theme-token", decl.prop);
|
|
4374
|
+
});
|
|
4375
|
+
root.walkRules((rule) => {
|
|
4376
|
+
for (const selector of rule.selectors ?? []) {
|
|
4377
|
+
const match = /\.([_a-z][\w-]*)/i.exec(selector);
|
|
4378
|
+
if (match?.[1]) add("selector", match[1]);
|
|
4379
|
+
}
|
|
4132
4380
|
});
|
|
4133
4381
|
} catch {}
|
|
4134
|
-
for (const match of source.matchAll(/@custom-variant\s+([^{\s]+)/g)) add("custom-variant", match[1]);
|
|
4135
|
-
for (const match of source.matchAll(/@(?:theme|utility|variant|layer)\s+([^{;\s]+)/g)) add("directive", match[1]);
|
|
4136
|
-
for (const match of source.matchAll(/--[\w-]+(?=\s*:)/g)) add("theme-token", match[0]);
|
|
4137
|
-
for (const match of source.matchAll(/\.([_a-z][\w-]*)\s*[{,]/gi)) add("selector", match[1]);
|
|
4138
4382
|
return tokens;
|
|
4139
4383
|
}
|
|
4140
4384
|
function scoreConfiguredTailwindV4SourceForRawSource(rawSource, entrySource) {
|
|
@@ -4150,7 +4394,7 @@ function selectTailwindV4GenerationCssSourceForOutput(outputFile, entries, rawSo
|
|
|
4150
4394
|
const generationSources = entries.filter((entry) => hasTailwindGenerationSource(entry.source));
|
|
4151
4395
|
if (generationSources.length <= 1) return generationSources[0];
|
|
4152
4396
|
const canMatchByOutputPath = Boolean(options.cwd || options.outputRoot || options.projectRoot);
|
|
4153
|
-
const selectByOutputPath = (candidates) => {
|
|
4397
|
+
const selectByOutputPath = (candidates, shouldUseScore = (score) => score > 0) => {
|
|
4154
4398
|
if (!canMatchByOutputPath) return;
|
|
4155
4399
|
const scoredSources = candidates.map((entry) => ({
|
|
4156
4400
|
entry,
|
|
@@ -4159,7 +4403,7 @@ function selectTailwindV4GenerationCssSourceForOutput(outputFile, entries, rawSo
|
|
|
4159
4403
|
outputRoot: options.outputRoot,
|
|
4160
4404
|
projectRoot: options.projectRoot
|
|
4161
4405
|
})
|
|
4162
|
-
})).filter((item) => item.score
|
|
4406
|
+
})).filter((item) => shouldUseScore(item.score)).sort((a, b) => b.score - a.score);
|
|
4163
4407
|
const bestScore = scoredSources[0]?.score;
|
|
4164
4408
|
const bestSources = bestScore ? scoredSources.filter((item) => item.score === bestScore) : [];
|
|
4165
4409
|
return bestSources.length === 1 ? bestSources[0]?.entry : void 0;
|
|
@@ -4173,10 +4417,12 @@ function selectTailwindV4GenerationCssSourceForOutput(outputFile, entries, rawSo
|
|
|
4173
4417
|
const bestSources = bestScore ? scoredSources.filter((item) => item.score === bestScore) : [];
|
|
4174
4418
|
return bestSources.length === 1 ? bestSources[0]?.entry : void 0;
|
|
4175
4419
|
};
|
|
4420
|
+
const explicitSources = generationSources.filter((entry) => hasExplicitTailwindV4Directive(entry.source));
|
|
4421
|
+
const candidates = explicitSources.length === 1 ? explicitSources : generationSources;
|
|
4422
|
+
const directoryIndexOutputPathMatched = selectByOutputPath(candidates, (score) => score >= 25e3 && score < 5e4);
|
|
4423
|
+
if (directoryIndexOutputPathMatched) return directoryIndexOutputPathMatched;
|
|
4176
4424
|
const rawSourceMatched = selectByRawSourceFingerprint(generationSources);
|
|
4177
4425
|
if (rawSourceMatched) return rawSourceMatched;
|
|
4178
|
-
const explicitSources = generationSources.filter((entry) => /@(?:config|source|plugin|custom-variant|theme|utility|variant|apply)\b/.test(entry.source));
|
|
4179
|
-
const candidates = explicitSources.length === 1 ? explicitSources : generationSources;
|
|
4180
4426
|
const outputPathMatched = selectByOutputPath(candidates);
|
|
4181
4427
|
if (outputPathMatched) return outputPathMatched;
|
|
4182
4428
|
if (candidates.length === 1) return candidates[0];
|
|
@@ -4195,8 +4441,7 @@ function createTemporaryCssAssetSourceResolver(entries) {
|
|
|
4195
4441
|
const seenEntryFiles = /* @__PURE__ */ new Set();
|
|
4196
4442
|
const queuedEntries = entries.filter((entry) => {
|
|
4197
4443
|
const entryFile = normalizeCssSourceKey(entry.file);
|
|
4198
|
-
|
|
4199
|
-
if (outputFile === entryFile || !outputFile.includes("/") || seenEntryFiles.has(entryFile)) return false;
|
|
4444
|
+
if (normalizeCssSourceKey(entry.outputFile) === entryFile || seenEntryFiles.has(entryFile)) return false;
|
|
4200
4445
|
seenEntryFiles.add(entryFile);
|
|
4201
4446
|
return true;
|
|
4202
4447
|
});
|
|
@@ -4209,14 +4454,18 @@ function createTemporaryCssAssetSourceResolver(entries) {
|
|
|
4209
4454
|
},
|
|
4210
4455
|
resolve(outputFile, rawSource) {
|
|
4211
4456
|
if (!isTemporaryCssAssetFile(outputFile)) return;
|
|
4212
|
-
const
|
|
4457
|
+
const outputFileKey = normalizeCssSourceKey(outputFile);
|
|
4458
|
+
const unusedEntries = queuedEntries.filter((item) => !usedEntryFiles.has(normalizeCssSourceKey(item.file)));
|
|
4459
|
+
const matchedOutputEntries = unusedEntries.filter((item) => normalizeCssSourceKey(item.outputFile) === outputFileKey);
|
|
4460
|
+
const usesMatchedOutputEntries = matchedOutputEntries.length > 0;
|
|
4461
|
+
const availableEntries = matchedOutputEntries.length > 0 ? matchedOutputEntries : unusedEntries.filter((item) => normalizeCssSourceKey(item.outputFile).includes("/"));
|
|
4213
4462
|
const scoredEntries = rawSource ? availableEntries.map((entry) => ({
|
|
4214
4463
|
entry,
|
|
4215
4464
|
score: scoreConfiguredTailwindV4SourceForRawSource(rawSource, entry.source)
|
|
4216
4465
|
})).filter((item) => item.score > 0).sort((a, b) => b.score - a.score) : [];
|
|
4217
4466
|
const bestScore = scoredEntries[0]?.score;
|
|
4218
4467
|
const bestEntries = bestScore ? scoredEntries.filter((item) => item.score === bestScore) : [];
|
|
4219
|
-
const entry = bestEntries.length === 1 ? bestEntries[0]?.entry : availableEntries.find((item) => hasTailwindGenerationSource(item.source));
|
|
4468
|
+
const entry = bestEntries.length === 1 ? bestEntries[0]?.entry : usesMatchedOutputEntries || rawSource == null ? availableEntries.find((item) => hasTailwindGenerationSource(item.source)) : void 0;
|
|
4220
4469
|
if (!entry) return;
|
|
4221
4470
|
usedEntryFiles.add(normalizeCssSourceKey(entry.file));
|
|
4222
4471
|
return {
|
|
@@ -4390,6 +4639,19 @@ function resolveSourceRootFromBundleGraph(config, bundle) {
|
|
|
4390
4639
|
return sourceRoots.size === 1 ? [...sourceRoots][0] : void 0;
|
|
4391
4640
|
}
|
|
4392
4641
|
//#endregion
|
|
4642
|
+
//#region src/bundlers/vite/web-css-compat.ts
|
|
4643
|
+
/**
|
|
4644
|
+
* Web target 的 Tailwind 兼容转换由 generator-css 负责;Vite 外层只处理非 Web 生成目标
|
|
4645
|
+
* 落到 WebView 产物时的最终兼容需求,避免同一份 CSS 在 dev/build 中被重复解析转换。
|
|
4646
|
+
*/
|
|
4647
|
+
function shouldApplyViteWebCssCompat(context, strategy) {
|
|
4648
|
+
if (strategy?.shouldApplyWebCssCompat?.(context) !== true) return false;
|
|
4649
|
+
return !context.currentGeneratorBranch.isWeb || context.currentGeneratorOptions.webCompat !== void 0;
|
|
4650
|
+
}
|
|
4651
|
+
function resolveViteWebCssCompatOptions(context) {
|
|
4652
|
+
return context.currentGeneratorBranch.isWeb ? context.currentGeneratorOptions.webCompat : context.currentGeneratorOptions.webCompat ?? true;
|
|
4653
|
+
}
|
|
4654
|
+
//#endregion
|
|
4393
4655
|
//#region src/bundlers/vite/generate-bundle.ts
|
|
4394
4656
|
function inferPlatformFromViteOutDir$1(outDir) {
|
|
4395
4657
|
const segment = outDir ? path.basename(path.normalize(outDir)) : void 0;
|
|
@@ -4401,6 +4663,7 @@ function createGenerateBundleHook(context) {
|
|
|
4401
4663
|
const state = createBundleBuildState();
|
|
4402
4664
|
const lastCssResultByFile = /* @__PURE__ */ new Map();
|
|
4403
4665
|
const lastCssSourceHashByFile = /* @__PURE__ */ new Map();
|
|
4666
|
+
const lastCssRawSourceHashByFile = /* @__PURE__ */ new Map();
|
|
4404
4667
|
let currentOutDir;
|
|
4405
4668
|
let currentSubpackageRoots;
|
|
4406
4669
|
const createInitialCssPipelineContext = (file) => {
|
|
@@ -4473,14 +4736,14 @@ function createGenerateBundleHook(context) {
|
|
|
4473
4736
|
resolveStylePlatform: () => generatorPlatform
|
|
4474
4737
|
};
|
|
4475
4738
|
const isWebGeneratorTarget = generatorBranch.isWeb;
|
|
4476
|
-
const shouldApplyWebCssCompat = context.cssPipelineStrategy
|
|
4739
|
+
const shouldApplyWebCssCompat = shouldApplyViteWebCssCompat(cssPipelineContext, context.cssPipelineStrategy);
|
|
4477
4740
|
const transformWebTargetCss = (css) => {
|
|
4478
4741
|
return context.cssPipelineStrategy?.transformGeneratedCss?.(css, {
|
|
4479
4742
|
...cssPipelineContext,
|
|
4480
|
-
defaultWebCssCompat: (value) => transformWebCssCompat(value,
|
|
4743
|
+
defaultWebCssCompat: (value) => transformWebCssCompat(value, resolveViteWebCssCompatOptions(cssPipelineContext)),
|
|
4481
4744
|
removeScopedPreflight: (value) => value,
|
|
4482
4745
|
shouldApplyWebCssCompat
|
|
4483
|
-
}) ?? (shouldApplyWebCssCompat ? transformWebCssCompat(css,
|
|
4746
|
+
}) ?? (shouldApplyWebCssCompat ? transformWebCssCompat(css, resolveViteWebCssCompatOptions(cssPipelineContext)) : css);
|
|
4484
4747
|
};
|
|
4485
4748
|
const isNativeAppStyleTarget = context.cssPipelineStrategy?.isNativeAppStyleTarget?.(cssPipelineContext) === true;
|
|
4486
4749
|
const isHarmonyAppStyleTarget = context.cssPipelineStrategy?.isHarmonyAppStyleTarget?.(cssPipelineContext) === true;
|
|
@@ -4491,6 +4754,9 @@ function createGenerateBundleHook(context) {
|
|
|
4491
4754
|
const sourceRoot = resolveWeappViteSourceRoot(resolvedConfig, opts.appType) ?? resolveSourceRootFromBundleGraph(resolvedConfig, bundle);
|
|
4492
4755
|
const outDir = resolvedConfig?.build?.outDir ? path.resolve(rootDir, resolvedConfig.build.outDir) : rootDir;
|
|
4493
4756
|
const defaultStyleOutputExtension = resolveMiniProgramStyleOutputExtension({ files: Object.keys(bundle) });
|
|
4757
|
+
const normalizeMiniProgramGeneratorRawSource = (source, outputFile) => {
|
|
4758
|
+
return isWebGeneratorTarget ? source : normalizeMiniProgramGeneratorCssSource(source, outputFile);
|
|
4759
|
+
};
|
|
4494
4760
|
await runtimeState.readyPromise;
|
|
4495
4761
|
debug("start");
|
|
4496
4762
|
onStart();
|
|
@@ -4516,7 +4782,7 @@ function createGenerateBundleHook(context) {
|
|
|
4516
4782
|
timingDetails[name] = (timingDetails[name] ?? 0) + Math.max(0, performance.now() - startedAt);
|
|
4517
4783
|
};
|
|
4518
4784
|
const timeTask = createBundleTaskTimer(recordTimingDetail);
|
|
4519
|
-
const emitOrReplayCssAsset = createCssAssetEmitter(this);
|
|
4785
|
+
const emitOrReplayCssAsset = createCssAssetEmitter(this, bundle);
|
|
4520
4786
|
const metrics = createEmptyMetrics();
|
|
4521
4787
|
const envFlags = resolveGenerateBundleEnvFlags();
|
|
4522
4788
|
const bundleFiles = Object.keys(bundle);
|
|
@@ -4583,15 +4849,20 @@ function createGenerateBundleHook(context) {
|
|
|
4583
4849
|
});
|
|
4584
4850
|
};
|
|
4585
4851
|
const resolveConfiguredTailwindV4CssEntryOutputFile = (sourceFile) => resolveViteCssPipelineOutputFile(sourceFile, opts, rootDir, isWebGeneratorTarget, shouldPreserveAppCssExtension, sourceRoot, defaultStyleOutputExtension, bundleFiles);
|
|
4586
|
-
const
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
if (!(context.cssPipelineStrategy?.shouldSelectConfiguredCssEntryRootSource?.({
|
|
4852
|
+
const shouldSelectConfiguredRootCssOutput = (outputFile) => {
|
|
4853
|
+
if (!opts.cssMatcher(outputFile) || !isRootStyleOutputFile(outputFile)) return false;
|
|
4854
|
+
return context.cssPipelineStrategy?.shouldSelectConfiguredCssEntryRootSource?.({
|
|
4590
4855
|
...cssPipelineContext,
|
|
4591
4856
|
isRootStyleOutputFile,
|
|
4592
4857
|
outputFile
|
|
4593
|
-
}) === true || cssPipelineContext.currentGeneratorBranch.isWeb
|
|
4594
|
-
|
|
4858
|
+
}) === true || cssPipelineContext.currentGeneratorBranch.isWeb;
|
|
4859
|
+
};
|
|
4860
|
+
const selectConfiguredRootCssSourceEntry = (outputFile, entries, originalFileNames) => {
|
|
4861
|
+
const matchedOriginalEntry = entries.find((entry) => originalFileNames?.some((originalFile) => normalizeConfiguredTailwindV4CssEntryFileKey(originalFile) === normalizeConfiguredTailwindV4CssEntryFileKey(entry.file)) === true);
|
|
4862
|
+
if (matchedOriginalEntry && outputFile.replace(/[?#].*$/, "").endsWith(".css")) return matchedOriginalEntry;
|
|
4863
|
+
if (!shouldSelectConfiguredRootCssOutput(outputFile)) return;
|
|
4864
|
+
const shouldRequireExplicitConfiguredEntry = !cssPipelineContext.currentGeneratorBranch.isWeb && opts.cssMatcher(outputFile) && isRootStyleOutputFile(outputFile);
|
|
4865
|
+
const generationEntries = entries.filter((entry) => hasTailwindGenerationSource(entry.source) && (!shouldRequireExplicitConfiguredEntry || configuredTailwindV4ExplicitCssEntryFileKeysForScope.has(normalizeConfiguredTailwindV4CssEntryFileKey(entry.file))));
|
|
4595
4866
|
if (generationEntries.length <= 1) return generationEntries[0];
|
|
4596
4867
|
const rootOutputEntries = generationEntries.filter((entry) => {
|
|
4597
4868
|
return !normalizeOutputPathKey(resolveConfiguredTailwindV4CssEntryOutputFile(entry.file).replace(/[?#].*$/, "")).includes("/");
|
|
@@ -4604,6 +4875,35 @@ function createGenerateBundleHook(context) {
|
|
|
4604
4875
|
if (mainPackageEntries.length === 1) return mainPackageEntries[0];
|
|
4605
4876
|
}
|
|
4606
4877
|
};
|
|
4878
|
+
const resolveConfiguredRootCssSourceStyle = (outputFile, entries, originalFileNames) => {
|
|
4879
|
+
const entry = selectConfiguredRootCssSourceEntry(outputFile, entries, originalFileNames);
|
|
4880
|
+
return entry ? {
|
|
4881
|
+
outputFile,
|
|
4882
|
+
rawSource: entry.source,
|
|
4883
|
+
sourceFile: entry.file
|
|
4884
|
+
} : void 0;
|
|
4885
|
+
};
|
|
4886
|
+
const shouldKeepCurrentRootMiniProgramStyleOutputAsImportShell = (outputFile, css) => {
|
|
4887
|
+
const normalizedOutputFile = normalizeOutputPathKey(outputFile.replace(/[?#].*$/, ""));
|
|
4888
|
+
return opts.cssMatcher(outputFile) && isMiniProgramStyleOutputFile(outputFile) && !normalizedOutputFile.includes("/") && shouldKeepRootMiniProgramStyleAsImportShell(context.cssPipelineStrategy?.shouldKeepRootMiniProgramStyleAsImportShell?.({
|
|
4889
|
+
...cssPipelineContext,
|
|
4890
|
+
css,
|
|
4891
|
+
file: outputFile
|
|
4892
|
+
}));
|
|
4893
|
+
};
|
|
4894
|
+
const shouldKeepCurrentRootCssOutputForConfiguredSource = (sourceFile, outputFile) => {
|
|
4895
|
+
const normalizedOutputFile = normalizeOutputPathKey(outputFile.replace(/[?#].*$/, ""));
|
|
4896
|
+
const isRootConfiguredStyleOutput = normalizedOutputFile.endsWith(".css") ? isRootStyleOutputFile(outputFile) : isMiniProgramStyleOutputFile(outputFile) && !normalizedOutputFile.includes("/");
|
|
4897
|
+
return typeof sourceFile === "string" && opts.cssMatcher(outputFile) && isRootConfiguredStyleOutput && !shouldKeepCurrentRootMiniProgramStyleOutputAsImportShell(outputFile) && configuredTailwindV4ExplicitCssEntryFileKeysForScope.has(normalizeConfiguredTailwindV4CssEntryFileKey(sourceFile));
|
|
4898
|
+
};
|
|
4899
|
+
const hasExplicitConfiguredRootCssEntryForOutput = (outputFile) => {
|
|
4900
|
+
if (cssPipelineContext.currentGeneratorBranch.isWeb || !opts.cssMatcher(outputFile) || !isRootStyleOutputFile(outputFile) || !shouldSelectConfiguredRootCssOutput(outputFile)) return false;
|
|
4901
|
+
return configuredTailwindV4CssSourceEntriesForScope.some((entry) => {
|
|
4902
|
+
if (!configuredTailwindV4ExplicitCssEntryFileKeysForScope.has(normalizeConfiguredTailwindV4CssEntryFileKey(entry.file))) return false;
|
|
4903
|
+
const entryOutputFile = resolveConfiguredTailwindV4CssEntryOutputFile(entry.file);
|
|
4904
|
+
return !normalizeOutputPathKey(entryOutputFile.replace(/[?#].*$/, "")).includes("/") || currentSubpackageRoots != null && !isSubpackageOutputFile(entryOutputFile, currentSubpackageRoots);
|
|
4905
|
+
});
|
|
4906
|
+
};
|
|
4607
4907
|
const { createScopedSourceCandidateGetter, createScopedSourceCandidateSourceGetter, shouldExcludeSubpackageSourceCandidates, shouldInjectCssIntoMainFromOutput } = createSubpackageSourceCandidateScope({
|
|
4608
4908
|
cssSourceFiles: configuredTailwindV4CssSourceEntriesForScope.map((entry) => entry.file),
|
|
4609
4909
|
getSourceCandidateSourcesForEntries,
|
|
@@ -4666,6 +4966,7 @@ function createGenerateBundleHook(context) {
|
|
|
4666
4966
|
if (mainCssEntry) {
|
|
4667
4967
|
const mainCssRawSource = typeof mainCssEntry.output.source === "string" ? mainCssEntry.output.source : Buffer.from(mainCssEntry.output.source).toString();
|
|
4668
4968
|
if (!hasTailwindApplyDirective(mainCssRawSource)) {
|
|
4969
|
+
const validationRawSource = normalizeMiniProgramGeneratorRawSource(mainCssRawSource, mainCssEntry.file);
|
|
4669
4970
|
const generatedCssSources = /* @__PURE__ */ new Set();
|
|
4670
4971
|
for (const [, record] of getViteProcessedCssAssetResults?.() ?? []) if (typeof record === "string") generatedCssSources.add(record);
|
|
4671
4972
|
else if (typeof record?.css === "string") generatedCssSources.add(record.css);
|
|
@@ -4673,7 +4974,7 @@ function createGenerateBundleHook(context) {
|
|
|
4673
4974
|
opts,
|
|
4674
4975
|
runtimeState,
|
|
4675
4976
|
candidates: filteredSourceCandidates,
|
|
4676
|
-
rawSource:
|
|
4977
|
+
rawSource: validationRawSource,
|
|
4677
4978
|
generatedCssSources,
|
|
4678
4979
|
file: mainCssEntry.file,
|
|
4679
4980
|
cssHandlerOptions: getCssHandlerOptions(mainCssEntry.file),
|
|
@@ -4691,6 +4992,9 @@ function createGenerateBundleHook(context) {
|
|
|
4691
4992
|
const cssExtensionByStem = collectCssExtensionByStem(bundleFiles, opts.cssMatcher);
|
|
4692
4993
|
const jsImportedCssFiles = collectJsImportedCssFiles(snapshot);
|
|
4693
4994
|
const runtimeLinkedCssFiles = /* @__PURE__ */ new Set([...collectRuntimeLinkedCssFiles(snapshot, cssExtensionByStem, defaultStyleOutputExtension), ...jsImportedCssFiles]);
|
|
4995
|
+
const shouldQueueTemporaryCssSourceEntry = (sourceFile, outputFile) => {
|
|
4996
|
+
return normalizeOutputPathKey(outputFile).includes("/") || typeof sourceFile === "string" && shouldSelectConfiguredRootCssOutput(outputFile) && configuredTailwindV4ExplicitCssEntryFileKeysForScope.has(normalizeConfiguredTailwindV4CssEntryFileKey(sourceFile));
|
|
4997
|
+
};
|
|
4694
4998
|
rememberRuntimeLinkedCssSources({
|
|
4695
4999
|
bundleFiles,
|
|
4696
5000
|
debug,
|
|
@@ -4713,7 +5017,7 @@ function createGenerateBundleHook(context) {
|
|
|
4713
5017
|
...[...runtimeLinkedCssFiles].filter((file) => !snapshot.sourceHashByFile.has(file)).map((file) => {
|
|
4714
5018
|
const outputFile = resolveViteCssPipelineOutputFile(file, opts, rootDir, isWebGeneratorTarget, shouldPreserveAppCssExtension, sourceRoot, defaultStyleOutputExtension, bundleFiles);
|
|
4715
5019
|
const inferredSourceStyle = resolveSourceStyleSourceFromOutputFile(outputFile, snapshot, outDir, sourceRoot, getCssSource, jsImportedCssFiles.has(file) ? getSourceCandidateSources : void 0, getConfiguredTailwindV4CssSourceEntries().map((entry) => [entry.file, entry.source]), debug);
|
|
4716
|
-
return inferredSourceStyle && currentSubpackageRoots ? {
|
|
5020
|
+
return inferredSourceStyle && currentSubpackageRoots && shouldQueueTemporaryCssSourceEntry(inferredSourceStyle.sourceFile, outputFile) ? {
|
|
4717
5021
|
file: inferredSourceStyle.sourceFile,
|
|
4718
5022
|
outputFile,
|
|
4719
5023
|
source: inferredSourceStyle.rawSource
|
|
@@ -4723,10 +5027,11 @@ function createGenerateBundleHook(context) {
|
|
|
4723
5027
|
file: remembered.sourceFile,
|
|
4724
5028
|
outputFile: remembered.outputFile,
|
|
4725
5029
|
source: remembered.rawSource
|
|
4726
|
-
})),
|
|
5030
|
+
})).filter((entry) => shouldQueueTemporaryCssSourceEntry(entry.file, entry.outputFile)),
|
|
4727
5031
|
...getConfiguredTailwindV4CssSourceEntries().map((entry) => {
|
|
4728
5032
|
const outputFile = resolveMatchedCssSourceOutputFile(entry.file);
|
|
4729
|
-
|
|
5033
|
+
const isExplicitConfiguredEntry = configuredTailwindV4ExplicitCssEntryFileKeysForScope.has(normalizeConfiguredTailwindV4CssEntryFileKey(entry.file));
|
|
5034
|
+
return outputFile && (normalizeOutputPathKey(outputFile).includes("/") || isExplicitConfiguredEntry && shouldSelectConfiguredRootCssOutput(outputFile)) ? {
|
|
4730
5035
|
file: entry.file,
|
|
4731
5036
|
outputFile,
|
|
4732
5037
|
source: entry.source
|
|
@@ -4903,6 +5208,7 @@ function createGenerateBundleHook(context) {
|
|
|
4903
5208
|
return await refreshRememberedCssSource?.(remembered) ?? remembered;
|
|
4904
5209
|
}));
|
|
4905
5210
|
rememberedCssSources = rememberedCssSources.filter((remembered) => {
|
|
5211
|
+
if (hasExplicitConfiguredRootCssEntryForOutput(outputFile) && !configuredTailwindV4ExplicitCssEntryFileKeysForScope.has(normalizeConfiguredTailwindV4CssEntryFileKey(remembered.sourceFile))) return false;
|
|
4906
5212
|
if (!configuredTailwindV4CssSourceFileKeysForScope.has(normalizeConfiguredTailwindV4CssEntryFileKey(remembered.sourceFile))) return true;
|
|
4907
5213
|
const matchedOutputFile = resolveMatchedOutputFileForCurrentAsset(remembered.sourceFile);
|
|
4908
5214
|
return !matchedOutputFile || normalizeOutputPathKey(matchedOutputFile) === normalizeOutputPathKey(outputFile);
|
|
@@ -4919,10 +5225,17 @@ function createGenerateBundleHook(context) {
|
|
|
4919
5225
|
hasUsableRememberedTailwindSource = false;
|
|
4920
5226
|
}
|
|
4921
5227
|
let outputCssHandlerOptions = getCssHandlerOptions(outputFile);
|
|
4922
|
-
|
|
5228
|
+
const configuredRootSourceStyle = resolveConfiguredRootCssSourceStyle(outputFile, getConfiguredTailwindV4CssSourceEntries(), originalSource.originalFileNames);
|
|
5229
|
+
const hasExplicitRememberedRootSource = rememberedCssSources.some((remembered) => configuredTailwindV4ExplicitCssEntryFileKeysForScope.has(normalizeConfiguredTailwindV4CssEntryFileKey(remembered.sourceFile)));
|
|
5230
|
+
if (configuredRootSourceStyle && (!hasUsableRememberedTailwindSource || !hasExplicitRememberedRootSource)) {
|
|
5231
|
+
rememberedCssSources = [configuredRootSourceStyle];
|
|
5232
|
+
hasUsableRememberedTailwindSource = true;
|
|
5233
|
+
debug("source style source inferred from configured root tailwind v4 css source: %s -> %s", outputFile, configuredRootSourceStyle.sourceFile);
|
|
5234
|
+
}
|
|
5235
|
+
if (!hasUsableRememberedTailwindSource && isTemporaryCssAssetFile(outputFile) && hasTailwindGenerationSource(rawSource)) {
|
|
4923
5236
|
const resolvedTemporarySource = temporaryCssAssetSourceResolver.resolve(outputFile, rawSource);
|
|
4924
5237
|
if (resolvedTemporarySource) {
|
|
4925
|
-
outputFile = resolveMatchedOutputFileForCurrentAsset(resolvedTemporarySource.sourceFile) ?? resolvedTemporarySource.outputFile;
|
|
5238
|
+
outputFile = shouldKeepCurrentRootCssOutputForConfiguredSource(resolvedTemporarySource.sourceFile, outputFile) ? outputFile : resolveMatchedOutputFileForCurrentAsset(resolvedTemporarySource.sourceFile) ?? resolvedTemporarySource.outputFile;
|
|
4926
5239
|
activeViteCssCacheFiles.add(normalizeViteCssCacheKey(outputFile));
|
|
4927
5240
|
outputCssHandlerOptions = getCssHandlerOptions(outputFile);
|
|
4928
5241
|
outputCssHandlerOptions = {
|
|
@@ -4942,50 +5255,19 @@ function createGenerateBundleHook(context) {
|
|
|
4942
5255
|
}
|
|
4943
5256
|
if (!hasUsableRememberedTailwindSource) {
|
|
4944
5257
|
const configuredTailwindV4CssSourceEntries = getConfiguredTailwindV4CssSourceEntries();
|
|
4945
|
-
const
|
|
4946
|
-
|
|
4947
|
-
|
|
4948
|
-
outputFile,
|
|
4949
|
-
rawSource: inferredWebviewRootSourceEntry.source,
|
|
4950
|
-
sourceFile: inferredWebviewRootSourceEntry.file
|
|
4951
|
-
} : void 0;
|
|
4952
|
-
const inferredOriginalSourceStyle = inferredSourceStyle ?? (outputFile === file ? void 0 : resolveSourceStyleSourceFromOutputFile(file, snapshot, outDir, sourceRoot, getCssSource, getSourceCandidateSources, configuredTailwindV4CssSourceEntries.map((entry) => [entry.file, entry.source]), debug)) ?? inferredWebviewRootSourceStyle;
|
|
4953
|
-
if (inferredOriginalSourceStyle) {
|
|
4954
|
-
outputFile = resolveMatchedOutputFileForCurrentAsset(inferredOriginalSourceStyle.sourceFile) ?? outputFile;
|
|
4955
|
-
activeViteCssCacheFiles.add(normalizeViteCssCacheKey(outputFile));
|
|
4956
|
-
outputCssHandlerOptions = getCssHandlerOptions(outputFile);
|
|
4957
|
-
rememberedCssSources = [{
|
|
4958
|
-
...inferredOriginalSourceStyle,
|
|
4959
|
-
outputFile
|
|
4960
|
-
}];
|
|
4961
|
-
} else if (isTemporaryCssAssetFile(outputFile) && configuredTailwindV4CssSourceEntries.length > 1) {
|
|
4962
|
-
const resolvedTemporarySource = temporaryCssAssetSourceResolver.resolve(outputFile, rawSource);
|
|
4963
|
-
if (resolvedTemporarySource) {
|
|
4964
|
-
outputFile = resolveMatchedOutputFileForCurrentAsset(resolvedTemporarySource.sourceFile) ?? resolvedTemporarySource.outputFile;
|
|
4965
|
-
activeViteCssCacheFiles.add(normalizeViteCssCacheKey(outputFile));
|
|
4966
|
-
outputCssHandlerOptions = getCssHandlerOptions(outputFile);
|
|
4967
|
-
outputCssHandlerOptions = {
|
|
4968
|
-
...outputCssHandlerOptions,
|
|
4969
|
-
isMainChunk: false
|
|
4970
|
-
};
|
|
4971
|
-
resolvedFromTemporaryCssAsset = true;
|
|
4972
|
-
usedConfiguredTailwindV4CssSourceFiles.add(normalizeOutputPathKey(resolvedTemporarySource.sourceFile));
|
|
4973
|
-
rememberedCssSources = [{
|
|
4974
|
-
outputFile,
|
|
4975
|
-
rawSource: resolvedTemporarySource.rawSource,
|
|
4976
|
-
sourceFile: resolvedTemporarySource.sourceFile
|
|
4977
|
-
}];
|
|
4978
|
-
debug("source style source inferred from temporary configured tailwind v4 css source: %s -> %s", outputFile, resolvedTemporarySource.sourceFile);
|
|
4979
|
-
}
|
|
4980
|
-
} else if (hasTailwindGenerationSource(rawSource) && (originalSource.originalFileNames?.length ?? 0) === 0) {
|
|
4981
|
-
const availableConfiguredTailwindV4CssSourceEntries = configuredTailwindV4CssSourceEntries.filter((entry) => !usedConfiguredTailwindV4CssSourceFiles.has(normalizeOutputPathKey(entry.file)));
|
|
4982
|
-
const configuredGenerationSource = selectTailwindV4GenerationCssSourceForOutput(outputFile, availableConfiguredTailwindV4CssSourceEntries, rawSource, {
|
|
5258
|
+
const isCurrentRootMiniProgramStyleOutput = opts.cssMatcher(outputFile) && isMiniProgramStyleOutputFile(outputFile) && !normalizeOutputPathKey(outputFile.replace(/[?#].*$/, "")).includes("/");
|
|
5259
|
+
if (isCurrentRootMiniProgramStyleOutput && hasTailwindGenerationSource(rawSource)) {
|
|
5260
|
+
const configuredGenerationSource = selectTailwindV4GenerationCssSourceForOutput(outputFile, configuredTailwindV4CssSourceEntries, rawSource, {
|
|
4983
5261
|
cwd: opts.tailwindcssBasedir,
|
|
4984
5262
|
outputRoot: outDir,
|
|
4985
5263
|
projectRoot: sourceRoot ?? rootDir
|
|
4986
5264
|
});
|
|
4987
|
-
|
|
4988
|
-
|
|
5265
|
+
const configuredGenerationOutputFile = configuredGenerationSource ? shouldKeepCurrentRootMiniProgramStyleOutputAsImportShell(outputFile, rawSource) ? resolveMatchedOutputFileForCurrentAsset(configuredGenerationSource.file) ?? outputFile : outputFile : void 0;
|
|
5266
|
+
const hasConfiguredGenerationSourceAlreadyUsed = configuredGenerationSource ? usedConfiguredTailwindV4CssSourceFiles.has(normalizeOutputPathKey(configuredGenerationSource.file)) : false;
|
|
5267
|
+
const hasConfiguredGenerationSourceAlreadyProcessed = configuredGenerationSource ? hasViteProcessedCssResultForSource(configuredGenerationSource.file, getViteProcessedCssAssetResults) : false;
|
|
5268
|
+
const shouldUseConfiguredGenerationSource = configuredGenerationSource && (!hasConfiguredGenerationSourceAlreadyUsed && !hasConfiguredGenerationSourceAlreadyProcessed || normalizeOutputPathKey(configuredGenerationOutputFile ?? outputFile) === normalizeOutputPathKey(outputFile));
|
|
5269
|
+
if (configuredGenerationSource && shouldUseConfiguredGenerationSource) {
|
|
5270
|
+
outputFile = configuredGenerationOutputFile ?? outputFile;
|
|
4989
5271
|
activeViteCssCacheFiles.add(normalizeViteCssCacheKey(outputFile));
|
|
4990
5272
|
outputCssHandlerOptions = getCssHandlerOptions(outputFile);
|
|
4991
5273
|
usedConfiguredTailwindV4CssSourceFiles.add(normalizeOutputPathKey(configuredGenerationSource.file));
|
|
@@ -4994,9 +5276,70 @@ function createGenerateBundleHook(context) {
|
|
|
4994
5276
|
rawSource: configuredGenerationSource.source,
|
|
4995
5277
|
sourceFile: configuredGenerationSource.file
|
|
4996
5278
|
}];
|
|
5279
|
+
hasUsableRememberedTailwindSource = true;
|
|
4997
5280
|
debug("source style source inferred from scoped configured tailwind v4 css source: %s -> %s", outputFile, configuredGenerationSource.file);
|
|
4998
5281
|
}
|
|
4999
5282
|
}
|
|
5283
|
+
if (!hasUsableRememberedTailwindSource) {
|
|
5284
|
+
const inferredSourceStyle = resolveSourceStyleSourceFromOutputFile(outputFile, snapshot, outDir, sourceRoot, getCssSource, getSourceCandidateSources, configuredTailwindV4CssSourceEntries.map((entry) => [entry.file, entry.source]), debug);
|
|
5285
|
+
const inferredWebviewRootSourceEntry = inferredSourceStyle ? void 0 : selectConfiguredRootCssSourceEntry(outputFile, configuredTailwindV4CssSourceEntries, originalSource.originalFileNames);
|
|
5286
|
+
const inferredWebviewRootSourceStyle = inferredWebviewRootSourceEntry ? {
|
|
5287
|
+
outputFile,
|
|
5288
|
+
rawSource: inferredWebviewRootSourceEntry.source,
|
|
5289
|
+
sourceFile: inferredWebviewRootSourceEntry.file
|
|
5290
|
+
} : void 0;
|
|
5291
|
+
const inferredOriginalSourceStyle = inferredSourceStyle ?? (outputFile === file ? void 0 : resolveSourceStyleSourceFromOutputFile(file, snapshot, outDir, sourceRoot, getCssSource, getSourceCandidateSources, configuredTailwindV4CssSourceEntries.map((entry) => [entry.file, entry.source]), debug)) ?? inferredWebviewRootSourceStyle;
|
|
5292
|
+
if (inferredOriginalSourceStyle) {
|
|
5293
|
+
const matchedOutputFile = normalizeOutputPathKey(inferredOriginalSourceStyle.outputFile) === normalizeOutputPathKey(outputFile) ? outputFile : resolveMatchedOutputFileForCurrentAsset(inferredOriginalSourceStyle.sourceFile) ?? outputFile;
|
|
5294
|
+
debug("source style output resolved: %s -> %s from %s", outputFile, matchedOutputFile, inferredOriginalSourceStyle.sourceFile);
|
|
5295
|
+
outputFile = matchedOutputFile;
|
|
5296
|
+
activeViteCssCacheFiles.add(normalizeViteCssCacheKey(outputFile));
|
|
5297
|
+
outputCssHandlerOptions = getCssHandlerOptions(outputFile);
|
|
5298
|
+
rememberedCssSources = [{
|
|
5299
|
+
...inferredOriginalSourceStyle,
|
|
5300
|
+
outputFile
|
|
5301
|
+
}];
|
|
5302
|
+
} else if (isTemporaryCssAssetFile(outputFile) && configuredTailwindV4CssSourceEntries.length > 1) {
|
|
5303
|
+
const resolvedTemporarySource = temporaryCssAssetSourceResolver.resolve(outputFile, rawSource);
|
|
5304
|
+
if (resolvedTemporarySource) {
|
|
5305
|
+
outputFile = shouldKeepCurrentRootCssOutputForConfiguredSource(resolvedTemporarySource.sourceFile, outputFile) ? outputFile : resolveMatchedOutputFileForCurrentAsset(resolvedTemporarySource.sourceFile) ?? resolvedTemporarySource.outputFile;
|
|
5306
|
+
activeViteCssCacheFiles.add(normalizeViteCssCacheKey(outputFile));
|
|
5307
|
+
outputCssHandlerOptions = getCssHandlerOptions(outputFile);
|
|
5308
|
+
outputCssHandlerOptions = {
|
|
5309
|
+
...outputCssHandlerOptions,
|
|
5310
|
+
isMainChunk: false
|
|
5311
|
+
};
|
|
5312
|
+
resolvedFromTemporaryCssAsset = true;
|
|
5313
|
+
usedConfiguredTailwindV4CssSourceFiles.add(normalizeOutputPathKey(resolvedTemporarySource.sourceFile));
|
|
5314
|
+
rememberedCssSources = [{
|
|
5315
|
+
outputFile,
|
|
5316
|
+
rawSource: resolvedTemporarySource.rawSource,
|
|
5317
|
+
sourceFile: resolvedTemporarySource.sourceFile
|
|
5318
|
+
}];
|
|
5319
|
+
debug("source style source inferred from temporary configured tailwind v4 css source: %s -> %s", outputFile, resolvedTemporarySource.sourceFile);
|
|
5320
|
+
}
|
|
5321
|
+
} else if (!isCurrentRootMiniProgramStyleOutput && hasTailwindGenerationSource(rawSource) && (originalSource.originalFileNames?.length ?? 0) === 0) {
|
|
5322
|
+
const availableConfiguredTailwindV4CssSourceEntries = configuredTailwindV4CssSourceEntries.filter((entry) => !usedConfiguredTailwindV4CssSourceFiles.has(normalizeOutputPathKey(entry.file)));
|
|
5323
|
+
const configuredGenerationSource = selectTailwindV4GenerationCssSourceForOutput(outputFile, availableConfiguredTailwindV4CssSourceEntries, rawSource, {
|
|
5324
|
+
cwd: opts.tailwindcssBasedir,
|
|
5325
|
+
outputRoot: outDir,
|
|
5326
|
+
projectRoot: sourceRoot ?? rootDir
|
|
5327
|
+
});
|
|
5328
|
+
if (configuredGenerationSource && !hasViteProcessedCssResultForSource(configuredGenerationSource.file, getViteProcessedCssAssetResults)) {
|
|
5329
|
+
outputFile = resolveMatchedOutputFileForCurrentAsset(configuredGenerationSource.file) ?? outputFile;
|
|
5330
|
+
activeViteCssCacheFiles.add(normalizeViteCssCacheKey(outputFile));
|
|
5331
|
+
outputCssHandlerOptions = getCssHandlerOptions(outputFile);
|
|
5332
|
+
usedConfiguredTailwindV4CssSourceFiles.add(normalizeOutputPathKey(configuredGenerationSource.file));
|
|
5333
|
+
rememberedCssSources = [{
|
|
5334
|
+
outputFile,
|
|
5335
|
+
rawSource: configuredGenerationSource.source,
|
|
5336
|
+
sourceFile: configuredGenerationSource.file
|
|
5337
|
+
}];
|
|
5338
|
+
hasUsableRememberedTailwindSource = true;
|
|
5339
|
+
debug("source style source inferred from scoped configured tailwind v4 css source: %s -> %s", outputFile, configuredGenerationSource.file);
|
|
5340
|
+
}
|
|
5341
|
+
}
|
|
5342
|
+
}
|
|
5000
5343
|
}
|
|
5001
5344
|
let rememberedCssSource = mergeRememberedCssSources(rememberedCssSources, outputFile);
|
|
5002
5345
|
if (rememberedCssSource && viteProcessedCssAsset && outputCssHandlerOptions.isMainChunk !== true && configuredTailwindV4CssSourceFileKeysForScope.has(normalizeConfiguredTailwindV4CssEntryFileKey(rememberedCssSource.sourceFile))) {
|
|
@@ -5014,7 +5357,7 @@ function createGenerateBundleHook(context) {
|
|
|
5014
5357
|
const shouldKeepImportedCssShell = isCssImportOnlyBundleAsset(bundle, file, rawSource);
|
|
5015
5358
|
const useRememberedCssSource = !shouldKeepImportedCssShell && rememberedCssSource != null && (normalizeOutputPathKey(rememberedCssSource.sourceFile) !== normalizeOutputPathKey(file) || !hasTailwindGenerationSource(rawSource) && hasTailwindGenerationSource(rememberedCssSource.rawSource));
|
|
5016
5359
|
const vitePipelineCssAsset = viteProcessedCssAsset || useRememberedCssSource;
|
|
5017
|
-
const generatorRawSource = vitePipelineCssAsset ? rememberedCssSource?.rawSource ?? rawSource : rawSource;
|
|
5360
|
+
const generatorRawSource = normalizeMiniProgramGeneratorRawSource(vitePipelineCssAsset ? rememberedCssSource?.rawSource ?? rawSource : rawSource, outputFile);
|
|
5018
5361
|
const hasRememberedApplySource = vitePipelineCssAsset && rememberedCssSource != null && hasTailwindApplyDirective(generatorRawSource);
|
|
5019
5362
|
const hasDifferentRememberedCssSource = rememberedCssSource != null && normalizeCssSourceForCompare(rememberedCssSource.rawSource) !== normalizeCssSourceForCompare(rawSource);
|
|
5020
5363
|
const hasCurrentTailwindGenerationDirective = hasTailwindSourceDirectives(rawSource, { importFallback: true }) || hasTailwindRootDirectives(rawSource, { importFallback: true }) || hasTailwindApplyDirective(rawSource);
|
|
@@ -5041,7 +5384,10 @@ function createGenerateBundleHook(context) {
|
|
|
5041
5384
|
...getCssHandlerOptions(generatorSourceFile),
|
|
5042
5385
|
isMainChunk: resolvedFromTemporaryCssAsset ? false : outputCssHandlerOptions.isMainChunk
|
|
5043
5386
|
} : getCssHandlerOptions(file);
|
|
5044
|
-
const
|
|
5387
|
+
const generatorSourceFileKey = normalizeConfiguredTailwindV4CssEntryFileKey(generatorSourceFile);
|
|
5388
|
+
const isExplicitGeneratorCssEntry = configuredTailwindV4ExplicitCssEntryFileKeysForScope.has(generatorSourceFileKey);
|
|
5389
|
+
const shouldUsePipelineSourceAsCssEntry = !isExplicitGeneratorCssEntry && vitePipelineCssAsset && opts.cssMatcher(generatorSourceFile) && hasTailwindGenerationSource(generatorRawSource);
|
|
5390
|
+
const generatorCssEntries = isExplicitGeneratorCssEntry || shouldUsePipelineSourceAsCssEntry ? [generatorSourceFile] : opts.cssEntries;
|
|
5045
5391
|
const generatorCssHandlerOptions = {
|
|
5046
5392
|
...cssHandlerOptions,
|
|
5047
5393
|
sourceOptions: {
|
|
@@ -5052,7 +5398,8 @@ function createGenerateBundleHook(context) {
|
|
|
5052
5398
|
};
|
|
5053
5399
|
const scopedSourceCandidateGetter = createScopedSourceCandidateGetter(outputFile, generatorCssHandlerOptions);
|
|
5054
5400
|
const scopedSourceCandidateSourceGetter = createScopedSourceCandidateSourceGetter(outputFile, generatorCssHandlerOptions);
|
|
5055
|
-
const
|
|
5401
|
+
const sourceTraceSources = scopedSourceCandidateSourceGetter ? await createScopedGeneratorSourceTraceMap(generatorRawSource, generatorSourceFile, scopedSourceCandidateSourceGetter) : void 0;
|
|
5402
|
+
const sourceTraceTokenSources = sourceTraceSources ? createCssTokenSourceMap(sourceTraceSources, opts) : void 0;
|
|
5056
5403
|
const sourceTraceSignature = createCssSourceTraceCacheSignature(sourceTraceTokenSources, opts);
|
|
5057
5404
|
const scopedGeneratorRuntime = await createScopedGeneratorRuntime$1(outputFile, generatorCssHandlerOptions, generatorRuntime, generatorRawSource, generatorSourceFile);
|
|
5058
5405
|
const annotateCss = (css) => annotateCssSourceTrace(css, {
|
|
@@ -5155,11 +5502,13 @@ function createGenerateBundleHook(context) {
|
|
|
5155
5502
|
const start = performance.now();
|
|
5156
5503
|
await runtimeState.readyPromise;
|
|
5157
5504
|
const previousCss = !vitePipelineCssAsset && useIncrementalMode && !hasRuntimeAffectingChanges && !snapshot.changedByType.css.has(file) ? getLastCssResult(lastCssResultByFile, outputFile, file) : void 0;
|
|
5158
|
-
const
|
|
5505
|
+
const generatorTransformRawSource = generatorRawSource;
|
|
5506
|
+
const previousGeneratorCss = previousCss && !isWebGeneratorTarget ? normalizeMiniProgramGeneratorRawSource(previousCss, outputFile) : previousCss;
|
|
5507
|
+
const generated = hasTailwindGenerationSource(generatorTransformRawSource) || hasBundlerGeneratedCssMarker(rawSource) ? await generateTailwindV4Css({
|
|
5159
5508
|
opts,
|
|
5160
5509
|
runtimeState,
|
|
5161
5510
|
runtime: scopedGeneratorRuntime,
|
|
5162
|
-
rawSource:
|
|
5511
|
+
rawSource: generatorTransformRawSource,
|
|
5163
5512
|
file: generatorSourceFile,
|
|
5164
5513
|
outputFile,
|
|
5165
5514
|
cssHandlerOptions: generatorCssHandlerOptions,
|
|
@@ -5169,8 +5518,8 @@ function createGenerateBundleHook(context) {
|
|
|
5169
5518
|
generatorPlatform,
|
|
5170
5519
|
styleHandler,
|
|
5171
5520
|
debug,
|
|
5172
|
-
previousCss,
|
|
5173
|
-
...vitePipelineCssAsset && !hasBundlerGeneratedCssMarker(rawSource) && normalizeCssSourceForCompare(rawSource) !== normalizeCssSourceForCompare(generatorRawSource) ? { userRawSource: normalizeGeneratorUserRawSource(rawSource, generatorSourceFile, assetSourceFile) } : {},
|
|
5521
|
+
previousCss: previousGeneratorCss,
|
|
5522
|
+
...vitePipelineCssAsset && !hasBundlerGeneratedCssMarker(rawSource) && normalizeCssSourceForCompare(rawSource) !== normalizeCssSourceForCompare(generatorRawSource) ? { userRawSource: normalizeMiniProgramGeneratorRawSource(normalizeGeneratorUserRawSource(rawSource, generatorSourceFile, assetSourceFile), outputFile) } : {},
|
|
5174
5523
|
...usesConfiguredTailwindV4FallbackSource ? { restoreLocalCssImports: false } : {}
|
|
5175
5524
|
}) : void 0;
|
|
5176
5525
|
if (generated) {
|
|
@@ -5200,9 +5549,17 @@ function createGenerateBundleHook(context) {
|
|
|
5200
5549
|
debug("css preserve web target: %s", outputFile);
|
|
5201
5550
|
return annotateCss(outputCss);
|
|
5202
5551
|
}
|
|
5203
|
-
|
|
5552
|
+
if (isPureLocalCssImportWrapper(generatorTransformRawSource)) {
|
|
5553
|
+
const tracedCss = annotateCss(generatorTransformRawSource);
|
|
5554
|
+
recordCssAssetResult?.(outputFile, tracedCss);
|
|
5555
|
+
metrics.css.elapsed += measureElapsed(start);
|
|
5556
|
+
metrics.css.transformed++;
|
|
5557
|
+
debug("css preserve mini-program import shell: %s", outputFile);
|
|
5558
|
+
return tracedCss;
|
|
5559
|
+
}
|
|
5560
|
+
const { css } = await styleHandler(generatorTransformRawSource, cssHandlerOptions);
|
|
5204
5561
|
const tracedCss = annotateCss(css);
|
|
5205
|
-
if (envFlags.debugCssDiff) debug("css diff %s: %s", generatorSourceFile, summarizeStringDiff(
|
|
5562
|
+
if (envFlags.debugCssDiff) debug("css diff %s: %s", generatorSourceFile, summarizeStringDiff(generatorTransformRawSource, tracedCss));
|
|
5206
5563
|
metrics.css.elapsed += measureElapsed(start);
|
|
5207
5564
|
metrics.css.transformed++;
|
|
5208
5565
|
return tracedCss;
|
|
@@ -5257,6 +5614,7 @@ function createGenerateBundleHook(context) {
|
|
|
5257
5614
|
bundle,
|
|
5258
5615
|
bundleFiles,
|
|
5259
5616
|
cache,
|
|
5617
|
+
changedCssFiles: snapshot.changedByType.css,
|
|
5260
5618
|
cssTaskFactories,
|
|
5261
5619
|
createScopedGeneratorRuntime: createScopedGeneratorRuntime$1,
|
|
5262
5620
|
createScopedSourceCandidateGetter,
|
|
@@ -5272,6 +5630,7 @@ function createGenerateBundleHook(context) {
|
|
|
5272
5630
|
getRememberedCssSources,
|
|
5273
5631
|
isNativeAppStyleTarget,
|
|
5274
5632
|
isWebGeneratorTarget,
|
|
5633
|
+
lastCssRawSourceHashByFile,
|
|
5275
5634
|
lastCssResultByFile,
|
|
5276
5635
|
lastCssSourceHashByFile,
|
|
5277
5636
|
markCssAssetProcessed,
|
|
@@ -5375,12 +5734,13 @@ function registerGeneratorDependencies(ctx, dependencies) {
|
|
|
5375
5734
|
throw error;
|
|
5376
5735
|
}
|
|
5377
5736
|
}
|
|
5378
|
-
function createCssHandlerOptions(opts, majorVersion, file, extraOptions = {}) {
|
|
5737
|
+
function createCssHandlerOptions(opts, majorVersion, file, outputRoot, extraOptions = {}) {
|
|
5738
|
+
const from = path.isAbsolute(file) ? file : outputRoot ? path.resolve(outputRoot, file) : file;
|
|
5379
5739
|
return {
|
|
5380
5740
|
...extraOptions,
|
|
5381
5741
|
cssPreflight: opts.cssPreflight,
|
|
5382
5742
|
isMainChunk: opts.mainCssChunkMatcher(file, opts.appType),
|
|
5383
|
-
postcssOptions: { options: { from
|
|
5743
|
+
postcssOptions: { options: { from } },
|
|
5384
5744
|
...normalizeStyleHandlerMajorVersion(majorVersion) === void 0 ? {} : { majorVersion: 4 }
|
|
5385
5745
|
};
|
|
5386
5746
|
}
|
|
@@ -5391,6 +5751,7 @@ function shouldGenerateCssByGenerator(opts, majorVersion, file, rawSource, proce
|
|
|
5391
5751
|
tailwindcssMajorVersion: majorVersion,
|
|
5392
5752
|
uniAppX: opts.uniAppX
|
|
5393
5753
|
});
|
|
5754
|
+
if (!generatorOptions.enabled) return false;
|
|
5394
5755
|
if (hasLocalCssImport(rawSource)) return false;
|
|
5395
5756
|
if (hasTailwindGeneratedCssMarkers(rawSource)) return true;
|
|
5396
5757
|
if (hasTailwindRootDirectives(rawSource, { importFallback: generatorOptions.importFallback })) return true;
|
|
@@ -5403,8 +5764,8 @@ function collectViteProcessedCssSources(getViteProcessedCssAssetResults) {
|
|
|
5403
5764
|
return [...getViteProcessedCssAssetResults?.() ?? []].map(([, record]) => typeof record === "string" ? record : record.css);
|
|
5404
5765
|
}
|
|
5405
5766
|
function finalizeWebCss(css, context, cssPipelineStrategy) {
|
|
5406
|
-
const shouldApplyWebCssCompat =
|
|
5407
|
-
const defaultWebCssCompat = (value) => transformWebCssCompat(value, context
|
|
5767
|
+
const shouldApplyWebCssCompat = shouldApplyViteWebCssCompat(context, cssPipelineStrategy);
|
|
5768
|
+
const defaultWebCssCompat = (value) => transformWebCssCompat(value, resolveViteWebCssCompatOptions(context));
|
|
5408
5769
|
return cssPipelineStrategy?.transformGeneratedCss?.(css, {
|
|
5409
5770
|
...context,
|
|
5410
5771
|
defaultWebCssCompat,
|
|
@@ -5450,6 +5811,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
5450
5811
|
const isNativeAppStyleTarget = cssPipelineStrategy?.isNativeAppStyleTarget?.(createCssPipelineContext("")) === true;
|
|
5451
5812
|
if (resolvedConfig?.command !== "build" && !isNativeAppStyleTarget) return;
|
|
5452
5813
|
const rootDir = resolvedConfig?.root ? path.resolve(resolvedConfig.root) : process$1.cwd();
|
|
5814
|
+
const outDir = resolvedConfig?.build?.outDir ? path.resolve(rootDir, resolvedConfig.build.outDir) : rootDir;
|
|
5453
5815
|
const sourceRoot = resolveWeappViteSourceRoot(resolvedConfig, opts.appType) ?? resolveSourceRootFromBundleGraph(resolvedConfig, bundle);
|
|
5454
5816
|
const sourceTraceTokenSources = getSourceCandidateSourcesForEntries ? createCssTokenSourceMap(getSourceCandidateSourcesForEntries(void 0), opts) : void 0;
|
|
5455
5817
|
const annotateCss = (css) => annotateCssSourceTrace(css, {
|
|
@@ -5496,7 +5858,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
5496
5858
|
const applyStyleSources = collectUniAppXHarmonyApplyStyleSources(bundle);
|
|
5497
5859
|
if (applyUtilities.size === 0 || applyStyleSources.length === 0) return cssSources;
|
|
5498
5860
|
const harmonyRuntime = /* @__PURE__ */ new Set([...runtime, ...applyUtilities]);
|
|
5499
|
-
const harmonyCssHandlerOptions = createCssHandlerOptions(opts, runtimeState.tailwindRuntime.majorVersion, "uni-app-x-harmony-apply.css", cssPipelineStrategy?.getCssHandlerExtraOptions?.({
|
|
5861
|
+
const harmonyCssHandlerOptions = createCssHandlerOptions(opts, runtimeState.tailwindRuntime.majorVersion, "uni-app-x-harmony-apply.css", outDir, cssPipelineStrategy?.getCssHandlerExtraOptions?.({
|
|
5500
5862
|
...createCssPipelineContext("uni-app-x-harmony-apply.css"),
|
|
5501
5863
|
file: "uni-app-x-harmony-apply.css"
|
|
5502
5864
|
}) ?? {});
|
|
@@ -5562,7 +5924,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
5562
5924
|
debug("css finalizer skip vite-processed css: %s", file);
|
|
5563
5925
|
return;
|
|
5564
5926
|
}
|
|
5565
|
-
const cssHandlerOptions = createCssHandlerOptions(opts, runtimeState.tailwindRuntime.majorVersion, file, cssPipelineStrategy?.getCssHandlerExtraOptions?.({
|
|
5927
|
+
const cssHandlerOptions = createCssHandlerOptions(opts, runtimeState.tailwindRuntime.majorVersion, file, outDir, cssPipelineStrategy?.getCssHandlerExtraOptions?.({
|
|
5566
5928
|
...createCssPipelineContext(file),
|
|
5567
5929
|
file
|
|
5568
5930
|
}) ?? {});
|
|
@@ -5570,11 +5932,21 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
5570
5932
|
...cssHandlerOptions,
|
|
5571
5933
|
isMainChunk: false
|
|
5572
5934
|
};
|
|
5935
|
+
const cleanRawSource = stripBundlerGeneratedCssMarkers(rawSource);
|
|
5936
|
+
if (cleanRawSource !== rawSource && cleanRawSource.trim().length === 0) {
|
|
5937
|
+
output.source = cleanRawSource;
|
|
5938
|
+
markCssAssetProcessed(output, file);
|
|
5939
|
+
recordCssAssetResult?.(file, cleanRawSource);
|
|
5940
|
+
opts.onUpdate(file, rawSource, cleanRawSource);
|
|
5941
|
+
debug("css finalizer strip empty marker asset: %s", file);
|
|
5942
|
+
return;
|
|
5943
|
+
}
|
|
5573
5944
|
const processed = isCssAssetProcessed(output, file);
|
|
5574
5945
|
const rememberedMainCssSource = processed && cssHandlerOptions.isMainChunk ? getRememberedMainCssSource?.(file) : void 0;
|
|
5575
|
-
const
|
|
5946
|
+
const resolvedGeneratorRawSource = rememberedMainCssSource?.rawSource ?? cleanRawSource;
|
|
5947
|
+
const generatorRawSource = generatorBranch.isWeb ? resolvedGeneratorRawSource : normalizeMiniProgramGeneratorCssSource(resolvedGeneratorRawSource, file);
|
|
5576
5948
|
const generatorSourceFile = rememberedMainCssSource?.sourceFile ?? file;
|
|
5577
|
-
const generatorCssHandlerOptions = rememberedMainCssSource ? createCssHandlerOptions(opts, runtimeState.tailwindRuntime.majorVersion, generatorSourceFile, cssPipelineStrategy?.getCssHandlerExtraOptions?.({
|
|
5949
|
+
const generatorCssHandlerOptions = rememberedMainCssSource ? createCssHandlerOptions(opts, runtimeState.tailwindRuntime.majorVersion, generatorSourceFile, outDir, cssPipelineStrategy?.getCssHandlerExtraOptions?.({
|
|
5578
5950
|
...createCssPipelineContext(generatorSourceFile),
|
|
5579
5951
|
file: generatorSourceFile
|
|
5580
5952
|
}) ?? {}) : cssHandlerOptions;
|
|
@@ -5582,11 +5954,12 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
5582
5954
|
...generatorCssHandlerOptions,
|
|
5583
5955
|
isMainChunk: false
|
|
5584
5956
|
} : cssUserHandlerOptions;
|
|
5585
|
-
const
|
|
5957
|
+
const generatorTransformRawSource = generatorRawSource;
|
|
5958
|
+
const generated = shouldGenerateCssByGenerator(opts, runtimeState.tailwindRuntime.majorVersion, file, generatorTransformRawSource, processed) ? await generateTailwindV4Css({
|
|
5586
5959
|
opts,
|
|
5587
5960
|
runtimeState,
|
|
5588
5961
|
runtime: generatorRuntime,
|
|
5589
|
-
rawSource:
|
|
5962
|
+
rawSource: generatorTransformRawSource,
|
|
5590
5963
|
file: generatorSourceFile,
|
|
5591
5964
|
outputFile: file,
|
|
5592
5965
|
cssHandlerOptions: generatorCssHandlerOptions,
|
|
@@ -5596,10 +5969,21 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
5596
5969
|
styleHandler: opts.styleHandler,
|
|
5597
5970
|
debug
|
|
5598
5971
|
}) : void 0;
|
|
5599
|
-
|
|
5972
|
+
if (!generated && !generatorBranch.isWeb && isPureLocalCssImportWrapper(generatorTransformRawSource)) {
|
|
5973
|
+
const nextCss = generatorTransformRawSource;
|
|
5974
|
+
if (nextCss !== rawSource) {
|
|
5975
|
+
output.source = nextCss;
|
|
5976
|
+
opts.onUpdate(file, rawSource, nextCss);
|
|
5977
|
+
}
|
|
5978
|
+
markCssAssetProcessed(output, file);
|
|
5979
|
+
recordCssAssetResult?.(file, nextCss);
|
|
5980
|
+
debug("css finalizer preserve mini-program import shell: %s", file);
|
|
5981
|
+
return;
|
|
5982
|
+
}
|
|
5983
|
+
const nextCss = annotateCss(generated?.css ?? (generatorBranch.isWeb ? finalizeWebCss(cleanRawSource, {
|
|
5600
5984
|
...createCssPipelineContext(file),
|
|
5601
5985
|
file
|
|
5602
|
-
}, cssPipelineStrategy) : (await opts.styleHandler(
|
|
5986
|
+
}, cssPipelineStrategy) : (await opts.styleHandler(generatorTransformRawSource, cssHandlerOptions)).css));
|
|
5603
5987
|
if (generated) {
|
|
5604
5988
|
registerGeneratorDependencies(this, generated.dependencies);
|
|
5605
5989
|
debug("css finalizer generated result: %s bytes=%d", file, nextCss.length);
|
|
@@ -5885,9 +6269,21 @@ function createViteCssMemory(options) {
|
|
|
5885
6269
|
function resolveHotTailwindCssModules(ctx, tailwindRootCssModuleIds) {
|
|
5886
6270
|
const modules = [];
|
|
5887
6271
|
const seenModules = /* @__PURE__ */ new Set();
|
|
6272
|
+
const root = ctx.server.config?.root ?? process$1.cwd();
|
|
6273
|
+
const outDir = ctx.server.config?.build?.outDir ? normalizeAbsoluteFilePath(path.resolve(root, ctx.server.config.build.outDir)) : void 0;
|
|
6274
|
+
const isHotSourceStyleModule = (id) => {
|
|
6275
|
+
if (!isSourceStyleRequest(id)) return false;
|
|
6276
|
+
const file = cleanUrl(id);
|
|
6277
|
+
if (isRootMiniProgramStyleUrl(file) || !isAbsoluteFilePath(file) && !file.startsWith("/")) return false;
|
|
6278
|
+
if (outDir && isAbsoluteFilePath(file)) {
|
|
6279
|
+
const normalizedFile = normalizeAbsoluteFilePath(file);
|
|
6280
|
+
if (normalizedFile === outDir || normalizedFile.startsWith(`${outDir}/`)) return false;
|
|
6281
|
+
}
|
|
6282
|
+
return true;
|
|
6283
|
+
};
|
|
5888
6284
|
const collectModule = (mod) => {
|
|
5889
6285
|
if (mod == null || seenModules.has(mod)) return;
|
|
5890
|
-
if (!
|
|
6286
|
+
if (!isHotSourceStyleModule(mod.id ?? mod.url)) return;
|
|
5891
6287
|
seenModules.add(mod);
|
|
5892
6288
|
ctx.server.moduleGraph.invalidateModule(mod);
|
|
5893
6289
|
modules.push(mod);
|
|
@@ -5923,6 +6319,29 @@ function resolveModuleHotUrl(mod) {
|
|
|
5923
6319
|
if (typeof mod.url === "string" && mod.url.length > 0) return mod.url;
|
|
5924
6320
|
if (typeof mod.id === "string" && mod.id.startsWith("/")) return mod.id;
|
|
5925
6321
|
}
|
|
6322
|
+
function isAbsoluteFilePath(file) {
|
|
6323
|
+
return path.isAbsolute(file) || /^[A-Z]:[\\/]/i.test(file) || file.startsWith("\\\\");
|
|
6324
|
+
}
|
|
6325
|
+
function normalizeAbsoluteFilePath(file) {
|
|
6326
|
+
if (/^[A-Z]:[\\/]/i.test(file) || file.startsWith("\\\\")) return slash(path.win32.resolve(file));
|
|
6327
|
+
return slash(path.resolve(file));
|
|
6328
|
+
}
|
|
6329
|
+
function isRootMiniProgramStyleUrl(file) {
|
|
6330
|
+
return /^\/[^/]+\.(?:wxss|acss|ttss|qss|jxss|tyss)(?:$|[?#])/i.test(file);
|
|
6331
|
+
}
|
|
6332
|
+
function resolveCssHotUrl(id, root) {
|
|
6333
|
+
const suffix = /[?#]/.test(id) ? id.slice(id.search(/[?#]/)) : "";
|
|
6334
|
+
const file = cleanUrl(id);
|
|
6335
|
+
if (/^\/(?![A-Z]:)/i.test(file) && !file.startsWith(slash(root))) {
|
|
6336
|
+
if (isRootMiniProgramStyleUrl(file)) return;
|
|
6337
|
+
return `${file}${suffix}`;
|
|
6338
|
+
}
|
|
6339
|
+
if (!isAbsoluteFilePath(file)) return;
|
|
6340
|
+
const normalizedRoot = normalizeAbsoluteFilePath(root);
|
|
6341
|
+
const normalizedFile = normalizeAbsoluteFilePath(file);
|
|
6342
|
+
if (!normalizedFile.startsWith(`${normalizedRoot}/`)) return;
|
|
6343
|
+
return `/${slash(path.relative(normalizedRoot, normalizedFile))}${suffix}`;
|
|
6344
|
+
}
|
|
5926
6345
|
function includesHotModule(modules, target) {
|
|
5927
6346
|
const targetUrl = resolveModuleHotUrl(target);
|
|
5928
6347
|
const targetId = target.id;
|
|
@@ -5931,24 +6350,40 @@ function includesHotModule(modules, target) {
|
|
|
5931
6350
|
return targetUrl !== void 0 && resolveModuleHotUrl(mod) === targetUrl || typeof targetId === "string" && targetId.length > 0 && mod.id === targetId;
|
|
5932
6351
|
});
|
|
5933
6352
|
}
|
|
6353
|
+
function createSupplementalHotUpdate(hotUrl, timestamp) {
|
|
6354
|
+
return {
|
|
6355
|
+
type: "js-update",
|
|
6356
|
+
timestamp,
|
|
6357
|
+
path: hotUrl,
|
|
6358
|
+
acceptedPath: hotUrl,
|
|
6359
|
+
explicitImportRequired: false,
|
|
6360
|
+
isWithinCircularImport: false
|
|
6361
|
+
};
|
|
6362
|
+
}
|
|
5934
6363
|
function hasSelfAcceptingNonStyleHotModule(modules) {
|
|
5935
6364
|
return modules.some((mod) => {
|
|
5936
6365
|
return !isSourceStyleRequest(mod.id ?? mod.url) && mod.isSelfAccepting === true;
|
|
5937
6366
|
});
|
|
5938
6367
|
}
|
|
5939
|
-
function sendSupplementalCssHotUpdates(ctx, cssModules) {
|
|
5940
|
-
const
|
|
5941
|
-
|
|
5942
|
-
|
|
5943
|
-
|
|
5944
|
-
|
|
5945
|
-
|
|
5946
|
-
|
|
5947
|
-
|
|
5948
|
-
|
|
5949
|
-
|
|
5950
|
-
|
|
5951
|
-
|
|
6368
|
+
function sendSupplementalCssHotUpdates(ctx, cssModules, fallbackCssIds = []) {
|
|
6369
|
+
const seenUrls = /* @__PURE__ */ new Set();
|
|
6370
|
+
const root = ctx.server.config?.root ?? process$1.cwd();
|
|
6371
|
+
const updates = [];
|
|
6372
|
+
for (const id of fallbackCssIds) {
|
|
6373
|
+
if (!isSourceStyleRequest(id)) continue;
|
|
6374
|
+
const hotUrl = resolveCssHotUrl(id, root);
|
|
6375
|
+
if (!hotUrl || seenUrls.has(hotUrl)) continue;
|
|
6376
|
+
seenUrls.add(hotUrl);
|
|
6377
|
+
updates.push(createSupplementalHotUpdate(hotUrl, ctx.timestamp));
|
|
6378
|
+
}
|
|
6379
|
+
for (const mod of cssModules) {
|
|
6380
|
+
if (includesHotModule(ctx.modules, mod)) continue;
|
|
6381
|
+
const moduleHotUrl = resolveModuleHotUrl(mod);
|
|
6382
|
+
const hotUrl = moduleHotUrl ? resolveCssHotUrl(moduleHotUrl, root) : void 0;
|
|
6383
|
+
if (!hotUrl || seenUrls.has(hotUrl)) continue;
|
|
6384
|
+
seenUrls.add(hotUrl);
|
|
6385
|
+
updates.push(createSupplementalHotUpdate(hotUrl, ctx.timestamp));
|
|
6386
|
+
}
|
|
5952
6387
|
if (updates.length === 0) return;
|
|
5953
6388
|
queueMicrotask(() => {
|
|
5954
6389
|
ctx.server.ws?.send?.({
|
|
@@ -6101,7 +6536,7 @@ function createRewriteCssImportsPlugins(options) {
|
|
|
6101
6536
|
const file = cleanUrl(id);
|
|
6102
6537
|
const normalizedCode = hasTailwindRootDirectives(code) || code.includes("@config") ? normalizeTailwindConfigDirectives(code, path.dirname(file)) : code;
|
|
6103
6538
|
await options.onCssSourceTransform?.(id, normalizedCode);
|
|
6104
|
-
const hasTailwindRoot = hasTailwindRootDirectives(normalizedCode);
|
|
6539
|
+
const hasTailwindRoot = hasTailwindRootDirectives(normalizedCode, { importFallback: true });
|
|
6105
6540
|
if (hasTailwindRoot) await options.onTailwindRootCss?.(id, normalizedCode);
|
|
6106
6541
|
const shouldGenerateInPreTransform = !options.shouldDeferGeneration?.(id, normalizedCode) && (hasTailwindRoot || options.shouldGenerateCss?.(id, normalizedCode));
|
|
6107
6542
|
if (options.shouldOwnTailwindGeneration && shouldGenerateInPreTransform) {
|
|
@@ -6263,6 +6698,7 @@ const SPECIAL_QUERY_RE$1 = /[?&](?:worker|sharedworker|raw|url)\b/;
|
|
|
6263
6698
|
const COMMON_JS_PROXY_RE = /\?commonjs-proxy/;
|
|
6264
6699
|
const VITE_CSS_HMR_MODULE_RE = /\b__vite__updateStyle\s*\(/;
|
|
6265
6700
|
const VITE_CSS_CONST_RE = /\bconst\s+__vite__css\s*=\s*("(?:\\[\s\S]|[^"])*")/;
|
|
6701
|
+
const DEFERRED_CSS_HMR_QUERY_RE = /[?&](?:hmr(?:[=&]|$)|t=\d+)/;
|
|
6266
6702
|
function decodeJsStringLiteral(literal) {
|
|
6267
6703
|
try {
|
|
6268
6704
|
return JSON.parse(literal);
|
|
@@ -6296,7 +6732,7 @@ function isViteServeCssRootRequest(id, command) {
|
|
|
6296
6732
|
return command === "serve" && isSourceStyleRequest(id) && !SPECIAL_QUERY_RE$1.test(id) && !COMMON_JS_PROXY_RE.test(id);
|
|
6297
6733
|
}
|
|
6298
6734
|
function isViteCssHmrModule(code, id, command) {
|
|
6299
|
-
return isViteServeStyleRequest(id, command) && VITE_CSS_HMR_MODULE_RE.test(code) && /[?&](?:direct|vue)(?:&|$)/.test(id);
|
|
6735
|
+
return isViteServeStyleRequest(id, command) && VITE_CSS_HMR_MODULE_RE.test(code) && (/[?&](?:direct|vue)(?:&|$)/.test(id) || DEFERRED_CSS_HMR_QUERY_RE.test(id));
|
|
6300
6736
|
}
|
|
6301
6737
|
function hasViteServeCssGenerationDirective(code) {
|
|
6302
6738
|
return hasTailwindRootDirectives(code) || hasTailwindSourceDirectives(code, { importFallback: true }) || hasTailwindApplyDirective(code);
|
|
@@ -6312,6 +6748,7 @@ function createViteServeCssGenerationPlugins(options) {
|
|
|
6312
6748
|
async transform(code, id) {
|
|
6313
6749
|
if (!options.shouldGenerate() || !isViteServeCssRootRequest(id, options.getCommand())) return;
|
|
6314
6750
|
if (!hasTailwindRootDirectives(code)) return;
|
|
6751
|
+
if (DEFERRED_CSS_HMR_QUERY_RE.test(id)) return;
|
|
6315
6752
|
await options.onTailwindRootCss?.(id, code);
|
|
6316
6753
|
const generatedCss = await options.generateCss(id, code, this);
|
|
6317
6754
|
if (generatedCss === void 0 || generatedCss === code) return;
|
|
@@ -6393,6 +6830,7 @@ const debug = createDebug();
|
|
|
6393
6830
|
const weappTailwindcssPackageDir = resolvePackageDir("weapp-tailwindcss");
|
|
6394
6831
|
const weappTailwindcssDirPosix = slash(weappTailwindcssPackageDir);
|
|
6395
6832
|
const SOURCE_CANDIDATE_SCAN_CACHE_MAX = 8;
|
|
6833
|
+
const WEB_HMR_RUNTIME_AFFECTING_DIRECTIVE_RE = /@(?:theme|source|config|plugin|apply)\b/;
|
|
6396
6834
|
const sourceCandidateScanSnapshotCache = new LRUCache({ max: SOURCE_CANDIDATE_SCAN_CACHE_MAX });
|
|
6397
6835
|
const ENV_PLATFORM_KEYS = [
|
|
6398
6836
|
"UNI_PLATFORM",
|
|
@@ -6427,9 +6865,6 @@ function inferPlatformFromOutDir(outDir) {
|
|
|
6427
6865
|
function isWebOrNativeAppPlatform(platform) {
|
|
6428
6866
|
return platform === "h5" || platform === "web" || platform?.startsWith("web-") === true || platform === "app" || platform === "app-plus" || platform?.startsWith("app-") === true;
|
|
6429
6867
|
}
|
|
6430
|
-
function applyViteWebCssCompat(css, options) {
|
|
6431
|
-
return transformWebCssCompat(css, options.compat);
|
|
6432
|
-
}
|
|
6433
6868
|
function isInternalUserDefinedOptions(options) {
|
|
6434
6869
|
return typeof options.onLoad === "function" && typeof options.mainCssChunkMatcher === "function" && typeof options.tailwindRuntime === "object" && typeof options.refreshTailwindcssRuntime === "function";
|
|
6435
6870
|
}
|
|
@@ -6469,7 +6904,6 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
6469
6904
|
const disabledOptions = resolvePluginDisabledState(disabled);
|
|
6470
6905
|
const tailwindcssMajorVersion = initialTailwindRuntime.majorVersion ?? 0;
|
|
6471
6906
|
if (!disabledOptions.plugin && tailwindcssMajorVersion !== 4) throw new Error("weapp-tailwindcss/vite 新生成管线仅支持 Tailwind CSS v4,请升级 tailwindcss 或停留在旧版 weapp-tailwindcss。");
|
|
6472
|
-
const shouldOwnTailwindGeneration = !disabledOptions.plugin;
|
|
6473
6907
|
const shouldRewriteCssImports = opts.rewriteCssImports === true;
|
|
6474
6908
|
let resolvedConfig;
|
|
6475
6909
|
const resolveViteStylePlatform = () => {
|
|
@@ -6488,6 +6922,7 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
6488
6922
|
tailwindcssMajorVersion,
|
|
6489
6923
|
uniAppX
|
|
6490
6924
|
});
|
|
6925
|
+
const shouldOwnTailwindGeneration = !disabledOptions.plugin && resolveCurrentGeneratorOptions().enabled;
|
|
6491
6926
|
const resolveCurrentGeneratorBranch = () => resolveGeneratorRuntimeBranch(resolveCurrentGeneratorOptions(), {
|
|
6492
6927
|
appType: opts.appType,
|
|
6493
6928
|
platform: resolveGeneratorPlatform(),
|
|
@@ -6608,8 +7043,11 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
6608
7043
|
const pendingSourceCandidateSyncs = /* @__PURE__ */ new Set();
|
|
6609
7044
|
const pendingSourceCandidateSyncByFile = /* @__PURE__ */ new Map();
|
|
6610
7045
|
const processedCssAssets = /* @__PURE__ */ new WeakSet();
|
|
7046
|
+
const processedCssAssetSourceByFile = /* @__PURE__ */ new Map();
|
|
6611
7047
|
const viteProcessedCssSourceFiles = /* @__PURE__ */ new Set();
|
|
6612
|
-
const
|
|
7048
|
+
const cleanGeneratedCssByFile = /* @__PURE__ */ new Map();
|
|
7049
|
+
const tracedGeneratedCssByFile = /* @__PURE__ */ new Map();
|
|
7050
|
+
const generatedClassSetByFile = /* @__PURE__ */ new Map();
|
|
6613
7051
|
const viteProcessedCssAssetResults = /* @__PURE__ */ new Map();
|
|
6614
7052
|
const cssMemory = createViteCssMemory({
|
|
6615
7053
|
debug,
|
|
@@ -6629,15 +7067,21 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
6629
7067
|
refreshRuntimeStateForAutoCssSources = refreshRuntimeState;
|
|
6630
7068
|
onLoad();
|
|
6631
7069
|
const getResolvedConfig = () => resolvedConfig;
|
|
6632
|
-
const
|
|
7070
|
+
const readCssAssetSource = (asset) => {
|
|
7071
|
+
return typeof asset.source === "string" ? asset.source : asset.source instanceof Uint8Array ? Buffer.from(asset.source).toString() : String(asset.source ?? "");
|
|
7072
|
+
};
|
|
7073
|
+
const markCssAssetProcessed = (asset, file) => {
|
|
6633
7074
|
processedCssAssets.add(asset);
|
|
7075
|
+
if (file) processedCssAssetSourceByFile.set(normalizeOutputPathKey(file), readCssAssetSource(asset));
|
|
6634
7076
|
};
|
|
6635
7077
|
const isCssAssetProcessed = (asset, file) => {
|
|
6636
7078
|
if (processedCssAssets.has(asset)) return true;
|
|
6637
7079
|
if (!file) return false;
|
|
7080
|
+
const source = readCssAssetSource(asset);
|
|
7081
|
+
if (processedCssAssetSourceByFile.get(normalizeOutputPathKey(file)) === source) return true;
|
|
6638
7082
|
const record = viteProcessedCssAssetResults.get(normalizeOutputPathKey(file));
|
|
6639
7083
|
if (!record) return false;
|
|
6640
|
-
return
|
|
7084
|
+
return source === record.css;
|
|
6641
7085
|
};
|
|
6642
7086
|
const recordGeneratorCandidates = (candidates) => {
|
|
6643
7087
|
recordedGeneratorCandidates = new Set(candidates);
|
|
@@ -6660,6 +7104,95 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
6660
7104
|
const cleanId = cleanUrl(id);
|
|
6661
7105
|
return cleanId.includes("/pages/") && /\.(?:vue|tsx?|jsx?)$/.test(cleanId);
|
|
6662
7106
|
};
|
|
7107
|
+
const hasWebHmrRuntimeAffectingDirectives = (source) => typeof source === "string" && WEB_HMR_RUNTIME_AFFECTING_DIRECTIVE_RE.test(source);
|
|
7108
|
+
let pendingHmrCandidateChange;
|
|
7109
|
+
let pendingHmrCssTargetFiles;
|
|
7110
|
+
let pendingFullHmrCssRegeneration = false;
|
|
7111
|
+
const normalizeHmrCssTargetFile = (file) => normalizeVitePersistentCacheKey(cleanUrl(file));
|
|
7112
|
+
const collectPendingHmrCssTargetFiles = (cssModules, fallbackCssIds) => {
|
|
7113
|
+
const targets = /* @__PURE__ */ new Set();
|
|
7114
|
+
const addTarget = (file) => {
|
|
7115
|
+
if (typeof file !== "string" || file.length === 0) return;
|
|
7116
|
+
const key = normalizeHmrCssTargetFile(file);
|
|
7117
|
+
if (cleanGeneratedCssByFile.has(key)) targets.add(key);
|
|
7118
|
+
};
|
|
7119
|
+
for (const mod of cssModules) {
|
|
7120
|
+
addTarget(mod.id);
|
|
7121
|
+
addTarget(mod.file);
|
|
7122
|
+
addTarget(mod.url);
|
|
7123
|
+
}
|
|
7124
|
+
for (const id of fallbackCssIds) addTarget(id);
|
|
7125
|
+
return targets.size > 0 ? targets : void 0;
|
|
7126
|
+
};
|
|
7127
|
+
const armPendingHmrCssTargetFiles = (cssModules, fallbackCssIds) => {
|
|
7128
|
+
if (!pendingHmrCandidateChange) {
|
|
7129
|
+
pendingHmrCssTargetFiles = void 0;
|
|
7130
|
+
return;
|
|
7131
|
+
}
|
|
7132
|
+
pendingHmrCssTargetFiles = collectPendingHmrCssTargetFiles(cssModules, fallbackCssIds);
|
|
7133
|
+
};
|
|
7134
|
+
const createViteSourceCandidateChange = (file, change, options = {}) => ({
|
|
7135
|
+
...change,
|
|
7136
|
+
file,
|
|
7137
|
+
runtimeAffecting: options.runtimeAffecting === true || isSourceStyleRequest(file) || hasWebHmrRuntimeAffectingDirectives(sourceCandidateCollector.source(file))
|
|
7138
|
+
});
|
|
7139
|
+
const clearPendingHmrCandidateChange = () => {
|
|
7140
|
+
pendingHmrCandidateChange = void 0;
|
|
7141
|
+
pendingHmrCssTargetFiles = void 0;
|
|
7142
|
+
pendingFullHmrCssRegeneration = false;
|
|
7143
|
+
};
|
|
7144
|
+
const queueHmrCandidateChange = (change) => {
|
|
7145
|
+
pendingFullHmrCssRegeneration = false;
|
|
7146
|
+
if (!pendingHmrCandidateChange) {
|
|
7147
|
+
pendingHmrCandidateChange = {
|
|
7148
|
+
file: change.file,
|
|
7149
|
+
runtimeAffecting: change.runtimeAffecting,
|
|
7150
|
+
addedCandidates: new Set(change.addedCandidates),
|
|
7151
|
+
removedCandidates: new Set(change.removedCandidates)
|
|
7152
|
+
};
|
|
7153
|
+
return;
|
|
7154
|
+
}
|
|
7155
|
+
for (const candidate of change.addedCandidates) {
|
|
7156
|
+
pendingHmrCandidateChange.addedCandidates.add(candidate);
|
|
7157
|
+
pendingHmrCandidateChange.removedCandidates.delete(candidate);
|
|
7158
|
+
}
|
|
7159
|
+
for (const candidate of change.removedCandidates) if (!pendingHmrCandidateChange.addedCandidates.delete(candidate)) pendingHmrCandidateChange.removedCandidates.add(candidate);
|
|
7160
|
+
pendingHmrCandidateChange.runtimeAffecting = pendingHmrCandidateChange.runtimeAffecting || change.runtimeAffecting;
|
|
7161
|
+
pendingHmrCandidateChange.file = change.file;
|
|
7162
|
+
};
|
|
7163
|
+
const queueFullHmrCssRegeneration = () => {
|
|
7164
|
+
pendingHmrCandidateChange = void 0;
|
|
7165
|
+
pendingHmrCssTargetFiles = void 0;
|
|
7166
|
+
pendingFullHmrCssRegeneration = true;
|
|
7167
|
+
};
|
|
7168
|
+
const applySourceCandidateHmrState = (change) => {
|
|
7169
|
+
if (isSourceStyleRequest(change.file)) {
|
|
7170
|
+
clearPendingHmrCandidateChange();
|
|
7171
|
+
return change;
|
|
7172
|
+
}
|
|
7173
|
+
const preserveDeletedCssInHmr = resolveCurrentGeneratorOptions().hmr.preserveDeletedCss;
|
|
7174
|
+
if (preserveDeletedCssInHmr && !change.runtimeAffecting) {
|
|
7175
|
+
if (change.addedCandidates.size > 0) queueHmrCandidateChange(change);
|
|
7176
|
+
else if (!pendingHmrCandidateChange) clearPendingHmrCandidateChange();
|
|
7177
|
+
return change;
|
|
7178
|
+
}
|
|
7179
|
+
clearPendingHmrCandidateChange();
|
|
7180
|
+
if (!preserveDeletedCssInHmr) queueFullHmrCssRegeneration();
|
|
7181
|
+
return change;
|
|
7182
|
+
};
|
|
7183
|
+
const resolvePendingHmrCandidateChange = (generatorCode, file) => {
|
|
7184
|
+
if (resolvedConfig?.command !== "serve" || !pendingHmrCandidateChange || pendingHmrCandidateChange.runtimeAffecting || pendingHmrCandidateChange.addedCandidates.size === 0 || resolveCurrentGeneratorOptions().target === "weapp" && hasUserCssLayerBlocks(generatorCode) || !cleanGeneratedCssByFile.has(file) || !generatedClassSetByFile.has(file) || pendingHmrCssTargetFiles !== void 0 && !pendingHmrCssTargetFiles.has(normalizeHmrCssTargetFile(file))) return;
|
|
7185
|
+
return pendingHmrCandidateChange;
|
|
7186
|
+
};
|
|
7187
|
+
const finishPendingHmrCssTargetFile = (file) => {
|
|
7188
|
+
if (!pendingHmrCandidateChange) return;
|
|
7189
|
+
if (!pendingHmrCssTargetFiles) {
|
|
7190
|
+
clearPendingHmrCandidateChange();
|
|
7191
|
+
return;
|
|
7192
|
+
}
|
|
7193
|
+
pendingHmrCssTargetFiles.delete(normalizeHmrCssTargetFile(file));
|
|
7194
|
+
if (pendingHmrCssTargetFiles.size === 0) clearPendingHmrCandidateChange();
|
|
7195
|
+
};
|
|
6663
7196
|
const hasSourceCandidateScanState = () => sourceCandidateScanSignature !== void 0;
|
|
6664
7197
|
const normalizeSourceScanDependency = (file) => path.normalize(path.resolve(cleanUrl(file)));
|
|
6665
7198
|
const isSourceScanDependency = (file) => sourceScanDependencies.has(normalizeSourceScanDependency(file));
|
|
@@ -6764,34 +7297,41 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
6764
7297
|
const waitForSourceCandidateSyncs = async () => {
|
|
6765
7298
|
while (pendingSourceCandidateSyncs.size > 0) await Promise.all(pendingSourceCandidateSyncs);
|
|
6766
7299
|
};
|
|
6767
|
-
const syncChangedSourceCandidateFile = (id) => {
|
|
6768
|
-
if (!shouldOwnTailwindGeneration || !isSourceCandidateRequest(id)) return Promise.resolve();
|
|
7300
|
+
const syncChangedSourceCandidateFile = (id, sourceOverride) => {
|
|
7301
|
+
if (!shouldOwnTailwindGeneration || !isSourceCandidateRequest(id)) return Promise.resolve(void 0);
|
|
6769
7302
|
const file = cleanUrl(id);
|
|
6770
|
-
|
|
7303
|
+
const runtimeAffectingByDependency = isSourceScanDependency(file);
|
|
7304
|
+
if (runtimeAffectingByDependency) invalidateSourceCandidateScan();
|
|
6771
7305
|
if (sourceScanMatcher && !sourceScanMatcher(file)) {
|
|
6772
|
-
sourceCandidateCollector.remove(file);
|
|
7306
|
+
const change = sourceCandidateCollector.remove(file);
|
|
6773
7307
|
cacheCurrentSourceCandidateScan();
|
|
6774
7308
|
if (isSourceStyleRequest(file)) return readFile(file, "utf8").then((source) => cssMemory.refreshRememberedCssSourceBySourceFile(file, source)).catch((error) => {
|
|
6775
7309
|
if ((typeof error === "object" && error !== null && "code" in error ? error.code : void 0) !== "ENOENT") debug("remembered css source watch refresh failed: %s %O", file, error);
|
|
6776
|
-
}).then(() => cssMemory.refreshRememberedCssSourceByCurrentFile(file)).then(() =>
|
|
6777
|
-
return cssMemory.refreshRememberedCssSourceByCurrentFile(file);
|
|
7310
|
+
}).then(() => cssMemory.refreshRememberedCssSourceByCurrentFile(file)).then(() => applySourceCandidateHmrState(createViteSourceCandidateChange(file, change, { runtimeAffecting: true })));
|
|
7311
|
+
return cssMemory.refreshRememberedCssSourceByCurrentFile(file).then(() => applySourceCandidateHmrState(createViteSourceCandidateChange(file, change, { runtimeAffecting: true })));
|
|
6778
7312
|
}
|
|
6779
|
-
const existingTask = pendingSourceCandidateSyncByFile.get(file);
|
|
6780
|
-
if (existingTask) return existingTask.then(
|
|
6781
|
-
|
|
7313
|
+
const existingTask = sourceOverride === void 0 ? pendingSourceCandidateSyncByFile.get(file) : void 0;
|
|
7314
|
+
if (existingTask) return existingTask.then(async () => {
|
|
7315
|
+
return await syncChangedSourceCandidateFile(id);
|
|
7316
|
+
});
|
|
7317
|
+
const task = (sourceOverride === void 0 ? sourceCandidateCollector.syncCurrentFile(id) : sourceCandidateCollector.syncCurrentSource(id, sourceOverride)).catch((error) => {
|
|
6782
7318
|
debug("source candidate watch sync failed: %s %O", id, error);
|
|
6783
|
-
}).then(() => {
|
|
7319
|
+
}).then((change) => {
|
|
6784
7320
|
cacheCurrentSourceCandidateScan();
|
|
7321
|
+
return change ? applySourceCandidateHmrState(createViteSourceCandidateChange(file, change, { runtimeAffecting: runtimeAffectingByDependency })) : void 0;
|
|
6785
7322
|
}).finally(() => {
|
|
6786
7323
|
pendingSourceCandidateSyncs.delete(task);
|
|
6787
7324
|
pendingSourceCandidateSyncByFile.delete(file);
|
|
6788
7325
|
});
|
|
6789
7326
|
pendingSourceCandidateSyncs.add(task);
|
|
6790
7327
|
pendingSourceCandidateSyncByFile.set(file, task);
|
|
6791
|
-
return task.then(
|
|
7328
|
+
return task.then(async (change) => {
|
|
7329
|
+
await cssMemory.refreshRememberedCssSourceByCurrentFile(file);
|
|
7330
|
+
return change;
|
|
7331
|
+
});
|
|
6792
7332
|
};
|
|
6793
7333
|
const recordCssAssetResult = (file, css) => {
|
|
6794
|
-
touchMapEntry(
|
|
7334
|
+
touchMapEntry(cleanGeneratedCssByFile, normalizeVitePersistentCacheKey(file), css);
|
|
6795
7335
|
};
|
|
6796
7336
|
const recordViteProcessedCssAssetResult = (file, css, options = {}) => {
|
|
6797
7337
|
const key = normalizeVitePersistentCacheKey(file);
|
|
@@ -6805,8 +7345,11 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
6805
7345
|
const getViteProcessedCssAssetResults = () => viteProcessedCssAssetResults.entries();
|
|
6806
7346
|
const getViteProcessedCssAssetResult = (file) => viteProcessedCssAssetResults.get(normalizeVitePersistentCacheKey(file));
|
|
6807
7347
|
const getViteCssCacheStats = () => ({
|
|
6808
|
-
|
|
6809
|
-
|
|
7348
|
+
cleanGeneratedCssByFile: cleanGeneratedCssByFile.size,
|
|
7349
|
+
cleanGeneratedCssByFileRaw: summarizeStringCache(cleanGeneratedCssByFile),
|
|
7350
|
+
tracedGeneratedCssByFile: tracedGeneratedCssByFile.size,
|
|
7351
|
+
tracedGeneratedCssByFileRaw: summarizeStringCache(tracedGeneratedCssByFile),
|
|
7352
|
+
generatedClassSetByFile: generatedClassSetByFile.size,
|
|
6810
7353
|
viteProcessedCssAssetResults: viteProcessedCssAssetResults.size,
|
|
6811
7354
|
viteProcessedCssAssetResultsRaw: summarizeViteProcessedCssResults(viteProcessedCssAssetResults),
|
|
6812
7355
|
...cssMemory.getStats(),
|
|
@@ -6816,7 +7359,9 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
6816
7359
|
});
|
|
6817
7360
|
const pruneViteCssCaches = (options) => {
|
|
6818
7361
|
const activeFiles = new Set([...options.activeFiles].map(normalizeVitePersistentCacheKey));
|
|
6819
|
-
for (const key of
|
|
7362
|
+
for (const key of cleanGeneratedCssByFile.keys()) if (!activeFiles.has(key)) cleanGeneratedCssByFile.delete(key);
|
|
7363
|
+
for (const key of tracedGeneratedCssByFile.keys()) if (!activeFiles.has(key)) tracedGeneratedCssByFile.delete(key);
|
|
7364
|
+
for (const key of generatedClassSetByFile.keys()) if (!activeFiles.has(key)) generatedClassSetByFile.delete(key);
|
|
6820
7365
|
for (const [key, record] of viteProcessedCssAssetResults) {
|
|
6821
7366
|
const outputKey = typeof record.outputFile === "string" ? normalizeVitePersistentCacheKey(record.outputFile) : void 0;
|
|
6822
7367
|
if (!activeFiles.has(key) && (outputKey == null || !activeFiles.has(outputKey))) viteProcessedCssAssetResults.delete(key);
|
|
@@ -6830,7 +7375,12 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
6830
7375
|
const rememberTailwindRootCssModule = (id) => {
|
|
6831
7376
|
if (!shouldOwnTailwindGeneration) return;
|
|
6832
7377
|
tailwindRootCssModuleIds.add(id);
|
|
6833
|
-
|
|
7378
|
+
const cleanId = cleanUrl(id);
|
|
7379
|
+
if (isSourceStyleRequest(cleanId)) tailwindRootCssModuleIds.add(cleanId);
|
|
7380
|
+
};
|
|
7381
|
+
const registerTailwindRootCss = async (id, code) => {
|
|
7382
|
+
rememberTailwindRootCssModule(id);
|
|
7383
|
+
await registerAutoCssSource(id, code);
|
|
6834
7384
|
};
|
|
6835
7385
|
const isUniViteProject = () => {
|
|
6836
7386
|
return resolvedConfig?.plugins?.some((plugin) => plugin.name.includes("uni")) ?? false;
|
|
@@ -6883,28 +7433,41 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
6883
7433
|
const shouldPreserveStyleOutputExtension = frameworkCssPipelineStrategy?.shouldPreserveStyleOutputExtension?.(cssPipelineContext) ?? frameworkCssPipelineStrategy?.isNativeAppStyleTarget?.(cssPipelineContext) === true;
|
|
6884
7434
|
const sourceRoot = resolveWeappViteSourceRoot(resolvedConfig, opts.appType);
|
|
6885
7435
|
const outputFile = resolveViteCssPipelineOutputFile(requestFile, opts, rootDir, currentGeneratorBranch.isWeb, shouldPreserveStyleOutputExtension, sourceRoot);
|
|
6886
|
-
const
|
|
7436
|
+
const generatorTransformCode = currentGeneratorBranch.isWeb ? generatorCode : normalizeMiniProgramGeneratorCssSource(generatorCode, outputFile);
|
|
7437
|
+
const fullRuntime = getSourceCandidates() ?? getRecordedGeneratorCandidates() ?? await ensureRuntimeClassSet();
|
|
7438
|
+
const pendingHmrChange = resolvePendingHmrCandidateChange(generatorCode, file);
|
|
7439
|
+
const forceFullHmrCssRegeneration = pendingFullHmrCssRegeneration || resolvedConfig?.command === "serve" && pendingHmrCandidateChange !== void 0 && pendingHmrChange === void 0;
|
|
7440
|
+
const runtime = pendingHmrChange ? new Set(pendingHmrChange.addedCandidates) : fullRuntime;
|
|
7441
|
+
if (pendingHmrChange && currentGeneratorOptions.target === "weapp" && filterUnsupportedMiniProgramTailwindV4Candidates(pendingHmrChange.addedCandidates).size === 0) {
|
|
7442
|
+
const previousTracedCss = tracedGeneratedCssByFile.get(file);
|
|
7443
|
+
if (previousTracedCss !== void 0) {
|
|
7444
|
+
finishPendingHmrCssTargetFile(file);
|
|
7445
|
+
return `${createBundlerGeneratedCssMarker("vite", normalizeViteProcessedCssFile(file))}\n${previousTracedCss}`;
|
|
7446
|
+
}
|
|
7447
|
+
}
|
|
6887
7448
|
const sourceCssHandlerOptions = transformCssHandlerOptions.getCssHandlerOptions(requestFile);
|
|
6888
7449
|
const outputCssHandlerOptions = transformCssHandlerOptions.getCssHandlerOptions(outputFile);
|
|
6889
7450
|
const cssHandlerOptions = {
|
|
6890
7451
|
...sourceCssHandlerOptions,
|
|
6891
7452
|
isMainChunk: outputCssHandlerOptions.isMainChunk
|
|
6892
7453
|
};
|
|
6893
|
-
const transientCssSource = transientAutoCssSources.get(file) ?? (hasTailwindRootDirectives(
|
|
7454
|
+
const transientCssSource = transientAutoCssSources.get(file) ?? (hasTailwindRootDirectives(generatorTransformCode, { importFallback: currentGeneratorOptions.importFallback }) || hasTailwindSourceDirectives(generatorTransformCode, { importFallback: currentGeneratorOptions.importFallback }) || hasTailwindApplyDirective(generatorTransformCode) ? {
|
|
6894
7455
|
base: path.dirname(path.resolve(file)),
|
|
6895
|
-
css:
|
|
7456
|
+
css: generatorTransformCode,
|
|
6896
7457
|
file: path.resolve(file)
|
|
6897
7458
|
} : void 0);
|
|
6898
7459
|
const shouldDeferEmptyScopedCssSource = transientCssSource == null && (frameworkCssPipelineStrategy?.shouldDeferEmptyScopedCssSource?.({
|
|
6899
7460
|
...cssPipelineContext,
|
|
6900
7461
|
cssHandlerOptions,
|
|
6901
|
-
generatorCode
|
|
7462
|
+
generatorCode: generatorTransformCode
|
|
6902
7463
|
}) ?? true);
|
|
6903
|
-
const
|
|
7464
|
+
const previousCss = pendingHmrChange && !forceFullHmrCssRegeneration ? cleanGeneratedCssByFile.get(file) : void 0;
|
|
7465
|
+
const previousGeneratorCss = previousCss && !currentGeneratorBranch.isWeb ? normalizeMiniProgramGeneratorCssSource(previousCss, outputFile) : previousCss;
|
|
7466
|
+
const generated = await hmrTimingRecorder.measure("generateCss.serve", () => generateTailwindV4Css({
|
|
6904
7467
|
opts,
|
|
6905
7468
|
runtimeState,
|
|
6906
7469
|
runtime,
|
|
6907
|
-
rawSource:
|
|
7470
|
+
rawSource: generatorTransformCode,
|
|
6908
7471
|
file,
|
|
6909
7472
|
outputFile,
|
|
6910
7473
|
cssHandlerOptions,
|
|
@@ -6914,25 +7477,45 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
6914
7477
|
generatorPlatform: resolveGeneratorPlatform(),
|
|
6915
7478
|
styleHandler,
|
|
6916
7479
|
debug,
|
|
6917
|
-
previousCss:
|
|
7480
|
+
previousCss: previousGeneratorCss,
|
|
7481
|
+
previousClassSet: pendingHmrChange && !forceFullHmrCssRegeneration ? generatedClassSetByFile.get(file) : void 0,
|
|
6918
7482
|
deferEmptyScopedCssSource: shouldDeferEmptyScopedCssSource,
|
|
7483
|
+
disableSourceScan: pendingHmrChange !== void 0,
|
|
6919
7484
|
restoreLocalCssImports: !currentGeneratorBranch.isWeb
|
|
7485
|
+
}), {
|
|
7486
|
+
file,
|
|
7487
|
+
memoryDebug: {
|
|
7488
|
+
cleanCacheHit: cleanGeneratedCssByFile.has(file),
|
|
7489
|
+
forceFullHmrCssRegeneration,
|
|
7490
|
+
pendingAddedCandidates: pendingHmrCandidateChange?.addedCandidates.size ?? 0,
|
|
7491
|
+
pendingCssTargets: pendingHmrCssTargetFiles?.size ?? 0,
|
|
7492
|
+
pendingResolved: pendingHmrChange !== void 0,
|
|
7493
|
+
runtimeCandidates: runtime.size,
|
|
7494
|
+
target: currentGeneratorOptions.target
|
|
7495
|
+
}
|
|
6920
7496
|
});
|
|
6921
|
-
if (!generated)
|
|
7497
|
+
if (!generated) {
|
|
7498
|
+
if (pendingHmrChange) finishPendingHmrCssTargetFile(file);
|
|
7499
|
+
else if (!pendingHmrCandidateChange) clearPendingHmrCandidateChange();
|
|
7500
|
+
return;
|
|
7501
|
+
}
|
|
6922
7502
|
const finalizedCss = finalizeViteMiniProgramCss(generated.css);
|
|
6923
|
-
const shouldApplyWebCssCompat =
|
|
6924
|
-
const
|
|
7503
|
+
const shouldApplyWebCssCompat = shouldApplyViteWebCssCompat(cssPipelineContext, frameworkCssPipelineStrategy);
|
|
7504
|
+
const outputCss = frameworkCssPipelineStrategy?.transformGeneratedCss?.(finalizedCss, {
|
|
6925
7505
|
...cssPipelineContext,
|
|
6926
|
-
defaultWebCssCompat: (css) =>
|
|
7506
|
+
defaultWebCssCompat: (css) => transformWebCssCompat(css, resolveViteWebCssCompatOptions(cssPipelineContext)),
|
|
6927
7507
|
removeScopedPreflight: removeScopedTailwindPreflightCss,
|
|
6928
7508
|
shouldApplyWebCssCompat
|
|
6929
|
-
}) ?? removeScopedTailwindPreflightCss(shouldApplyWebCssCompat ?
|
|
7509
|
+
}) ?? removeScopedTailwindPreflightCss(shouldApplyWebCssCompat ? transformWebCssCompat(finalizedCss, resolveViteWebCssCompatOptions(cssPipelineContext)) : finalizedCss);
|
|
7510
|
+
const tracedCss = annotateCssSourceTrace(outputCss, {
|
|
6930
7511
|
opts,
|
|
6931
7512
|
tokenSources: createCssTokenSourceMap(getSourceCandidateSourcesForEntries(void 0), opts)
|
|
6932
7513
|
});
|
|
6933
7514
|
for (const dependency of generated.dependencies) hookContext?.addWatchFile?.(dependency);
|
|
6934
|
-
|
|
6935
|
-
|
|
7515
|
+
cleanGeneratedCssByFile.set(file, outputCss);
|
|
7516
|
+
tracedGeneratedCssByFile.set(file, tracedCss);
|
|
7517
|
+
generatedClassSetByFile.set(file, new Set(generated.classSet));
|
|
7518
|
+
const shouldInjectGeneratedCssIntoMain = mainCssChunkMatcher(outputFile, opts.appType) || hasTailwindRootDirectives(generatorTransformCode, { importFallback: currentGeneratorOptions.importFallback }) && !normalizeOutputPathKey(outputFile).includes("/");
|
|
6936
7519
|
recordViteProcessedCssAssetResult(file, tracedCss, {
|
|
6937
7520
|
injectIntoMain: shouldInjectGeneratedCssIntoMain,
|
|
6938
7521
|
outputFile
|
|
@@ -6948,7 +7531,9 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
6948
7531
|
});
|
|
6949
7532
|
markViteProcessedCssSource(file);
|
|
6950
7533
|
rememberTailwindRootCssModule(id);
|
|
6951
|
-
recordGeneratorCandidates(
|
|
7534
|
+
recordGeneratorCandidates(fullRuntime);
|
|
7535
|
+
if (pendingHmrChange) finishPendingHmrCssTargetFile(file);
|
|
7536
|
+
else if (!pendingHmrCandidateChange) clearPendingHmrCandidateChange();
|
|
6952
7537
|
cssMemory.rememberCssSource({
|
|
6953
7538
|
outputFile,
|
|
6954
7539
|
rawSource: code,
|
|
@@ -6961,7 +7546,7 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
6961
7546
|
getAppType: () => opts.appType,
|
|
6962
7547
|
generateTailwindCss: generateTailwindCssForVitePipeline,
|
|
6963
7548
|
rootImport: shouldOwnTailwindGeneration ? `${weappTailwindcssDirPosix}/generator-placeholder.css` : void 0,
|
|
6964
|
-
onTailwindRootCss:
|
|
7549
|
+
onTailwindRootCss: registerTailwindRootCss,
|
|
6965
7550
|
onCssSourceTransform: (id, code) => cssMemory.refreshRememberedCssSourceBySourceFile(id, code),
|
|
6966
7551
|
shouldGenerateCss: (_id, code) => hasVitePipelineTailwindGenerationDirective(code),
|
|
6967
7552
|
shouldDeferGeneration: (_id, code) => !shouldRewriteCssImports && hasTailwindRootDirectives(code, { importFallback: resolveCurrentGeneratorOptions().importFallback }),
|
|
@@ -7067,7 +7652,10 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7067
7652
|
let transformedCode = code;
|
|
7068
7653
|
if (shouldOwnTailwindGeneration && !resolveCurrentGeneratorBranch().isWeb && isCSSRequest(id)) transformedCode = transformEarlyMiniProgramCss(code);
|
|
7069
7654
|
const shouldReturnTransformedCode = transformedCode !== code;
|
|
7070
|
-
if (shouldOwnTailwindGeneration)
|
|
7655
|
+
if (shouldOwnTailwindGeneration) {
|
|
7656
|
+
cssMemory.rememberKnownSfcSource(id, transformedCode);
|
|
7657
|
+
if (isCSSRequest(id) && hasTailwindRootDirectives(transformedCode, { importFallback: resolveCurrentGeneratorOptions().importFallback })) rememberTailwindRootCssModule(id);
|
|
7658
|
+
}
|
|
7071
7659
|
if (!shouldOwnTailwindGeneration || !isSourceCandidateRequest(id) || !shouldCollectTransformedSourceCandidates(id)) {
|
|
7072
7660
|
if (shouldReturnTransformedCode) return {
|
|
7073
7661
|
code: transformedCode,
|
|
@@ -7097,8 +7685,10 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7097
7685
|
if (shouldOwnTailwindGeneration && isSourceCandidateRequest(id)) invalidateRecordedGeneratorCandidates();
|
|
7098
7686
|
if (isSourceScanDependency(id)) invalidateSourceCandidateScan();
|
|
7099
7687
|
if (change.event === "delete") {
|
|
7100
|
-
|
|
7688
|
+
const file = cleanUrl(id);
|
|
7689
|
+
const sourceCandidateChange = sourceCandidateCollector.remove(file);
|
|
7101
7690
|
cacheCurrentSourceCandidateScan();
|
|
7691
|
+
applySourceCandidateHmrState(createViteSourceCandidateChange(file, sourceCandidateChange, { runtimeAffecting: isSourceScanDependency(file) }));
|
|
7102
7692
|
return;
|
|
7103
7693
|
}
|
|
7104
7694
|
await syncChangedSourceCandidateFile(id);
|
|
@@ -7107,18 +7697,36 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7107
7697
|
async handleHotUpdate(ctx) {
|
|
7108
7698
|
return hmrTimingRecorder.measure("sourceCandidates.handleHotUpdate", async () => {
|
|
7109
7699
|
const isSourceCandidateHotUpdate = shouldOwnTailwindGeneration && isSourceCandidateRequest(ctx.file);
|
|
7110
|
-
|
|
7700
|
+
if (isSourceCandidateHotUpdate && isSourceStyleRequest(ctx.file)) for (const mod of ctx.modules) {
|
|
7701
|
+
if (mod.id) rememberTailwindRootCssModule(mod.id);
|
|
7702
|
+
if (mod.url) rememberTailwindRootCssModule(mod.url);
|
|
7703
|
+
if (mod.file) rememberTailwindRootCssModule(mod.file);
|
|
7704
|
+
}
|
|
7705
|
+
const canReadHotSource = typeof ctx.read === "function";
|
|
7706
|
+
const hotSource = isSourceCandidateHotUpdate && canReadHotSource ? await ctx.read().catch(() => void 0) : void 0;
|
|
7707
|
+
const sourceCandidateChange = await syncChangedSourceCandidateFile(ctx.file, hotSource);
|
|
7111
7708
|
const isWebLikeHotUpdate = isCurrentWebLikeStylePlatform();
|
|
7709
|
+
let canUseHmrCandidateAppend = false;
|
|
7112
7710
|
if (isSourceCandidateHotUpdate) {
|
|
7113
7711
|
invalidateRecordedGeneratorCandidates();
|
|
7114
|
-
|
|
7115
|
-
|
|
7116
|
-
|
|
7712
|
+
const preserveDeletedCssInHmr = resolveCurrentGeneratorOptions().hmr.preserveDeletedCss;
|
|
7713
|
+
canUseHmrCandidateAppend = preserveDeletedCssInHmr && !isSourceStyleRequest(ctx.file) && sourceCandidateChange !== void 0 && !sourceCandidateChange.runtimeAffecting;
|
|
7714
|
+
if (!canUseHmrCandidateAppend) {
|
|
7715
|
+
if (sourceCandidateChange === void 0) {
|
|
7716
|
+
clearPendingHmrCandidateChange();
|
|
7717
|
+
if (!preserveDeletedCssInHmr && !isSourceStyleRequest(ctx.file)) queueFullHmrCssRegeneration();
|
|
7718
|
+
}
|
|
7719
|
+
if (isWebLikeHotUpdate) {
|
|
7720
|
+
await refreshRuntimeStateForAutoCssSources?.(true);
|
|
7721
|
+
await syncSourceCandidateScan({ force: true });
|
|
7722
|
+
}
|
|
7117
7723
|
}
|
|
7118
7724
|
}
|
|
7725
|
+
if (isSourceCandidateHotUpdate) await waitForSourceCandidateSyncs();
|
|
7119
7726
|
const cssModules = resolveHotTailwindCssModules(ctx, tailwindRootCssModuleIds);
|
|
7120
7727
|
const sourceModules = isSourceCandidateHotUpdate && !isSourceStyleRequest(ctx.file) ? resolveHotSourceModules(ctx) : ctx.modules;
|
|
7121
|
-
|
|
7728
|
+
const hasHmrCandidateAppend = pendingHmrCandidateChange !== void 0 && !pendingHmrCandidateChange.runtimeAffecting && pendingHmrCandidateChange.addedCandidates.size > 0 || canUseHmrCandidateAppend && sourceCandidateChange !== void 0 && sourceCandidateChange.addedCandidates.size > 0;
|
|
7729
|
+
if (isSourceCandidateHotUpdate && !isSourceStyleRequest(ctx.file) && !hasHmrCandidateAppend && !isWebLikeHotUpdate && (!hasSelfAcceptingNonStyleHotModule(sourceModules) && cssModules.length === 0 || cssModules.length > 0 && isUniViteProject())) {
|
|
7122
7730
|
sendFullReloadForUnresolvedHotUpdate(ctx);
|
|
7123
7731
|
return [];
|
|
7124
7732
|
}
|
|
@@ -7126,7 +7734,10 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7126
7734
|
sendFullReloadForUnresolvedHotUpdate(ctx);
|
|
7127
7735
|
return [];
|
|
7128
7736
|
}
|
|
7129
|
-
|
|
7737
|
+
const shouldSendSupplementalCssHotUpdates = !(isWebLikeHotUpdate && isSourceCandidateHotUpdate && !isSourceStyleRequest(ctx.file) && resolveCurrentGeneratorOptions().hmr.preserveDeletedCss && sourceCandidateChange !== void 0 && !sourceCandidateChange.runtimeAffecting && sourceCandidateChange.addedCandidates.size === 0 && sourceCandidateChange.removedCandidates.size > 0);
|
|
7738
|
+
const supplementalCssFallbackIds = /* @__PURE__ */ new Set([...tailwindRootCssModuleIds, ...viteProcessedCssSourceFiles]);
|
|
7739
|
+
if (hasHmrCandidateAppend) armPendingHmrCssTargetFiles(cssModules, supplementalCssFallbackIds);
|
|
7740
|
+
if (shouldSendSupplementalCssHotUpdates) sendSupplementalCssHotUpdates(ctx, cssModules, supplementalCssFallbackIds);
|
|
7130
7741
|
if (isWebLikeHotUpdate && isSourceCandidateHotUpdate && !isSourceStyleRequest(ctx.file)) return;
|
|
7131
7742
|
if (isSourceCandidateHotUpdate && !isSourceStyleRequest(ctx.file) && cssModules.length > 0) return [...sourceModules, ...cssModules];
|
|
7132
7743
|
return cssModules.length > 0 ? [...ctx.modules, ...cssModules] : void 0;
|
|
@@ -7141,7 +7752,7 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7141
7752
|
...createViteServeCssGenerationPlugins({
|
|
7142
7753
|
generateCss: generateTailwindCssForVitePipeline,
|
|
7143
7754
|
getCommand: () => resolvedConfig?.command,
|
|
7144
|
-
onTailwindRootCss:
|
|
7755
|
+
onTailwindRootCss: registerTailwindRootCss,
|
|
7145
7756
|
shouldGenerate: () => shouldOwnTailwindGeneration
|
|
7146
7757
|
}),
|
|
7147
7758
|
createViteServeJsTransformPlugin({
|
|
@@ -7326,13 +7937,13 @@ const uniAppCssPipelineStrategy = {
|
|
|
7326
7937
|
return context.isWebGeneratorTarget && isUniAppWebviewAppBundle(context.bundleFiles);
|
|
7327
7938
|
},
|
|
7328
7939
|
shouldSelectConfiguredCssEntryRootSource(context) {
|
|
7329
|
-
return context.
|
|
7940
|
+
return context.opts.cssMatcher(context.outputFile) && context.isRootStyleOutputFile(context.outputFile);
|
|
7330
7941
|
},
|
|
7331
7942
|
shouldTransformServeJs(context) {
|
|
7332
7943
|
return !context.currentGeneratorBranch.isWeb || isUniAppWebviewStylePlatform(context.resolveStylePlatform());
|
|
7333
7944
|
},
|
|
7334
7945
|
transformGeneratedCss(css, context) {
|
|
7335
|
-
const webCss = context.shouldApplyWebCssCompat ?
|
|
7946
|
+
const webCss = context.shouldApplyWebCssCompat ? context.defaultWebCssCompat(css) : css;
|
|
7336
7947
|
const safeCss = isUniAppWebviewStylePlatform(context.resolveStylePlatform()) ? transformWebCssSafeSelectors(webCss, { escapeMap: context.opts.escapeMap }) : webCss;
|
|
7337
7948
|
return context.removeScopedPreflight(safeCss);
|
|
7338
7949
|
}
|