weapp-tailwindcss 5.1.3 → 5.1.5
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/auto-CrJJc5rK.mjs +13 -0
- package/dist/bundlers/shared/generator-css/generation-helpers.d.ts +8 -2
- package/dist/bundlers/shared/generator-css/local-imports.d.ts +1 -10
- package/dist/bundlers/shared/generator-css/source-resolver/metadata.d.ts +5 -1
- package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/tailwind-v4-css-source.d.ts +6 -3
- package/dist/bundlers/vite/generate-bundle/temporary-css-assets.d.ts +1 -1
- package/dist/bundlers/vite/hot-css-modules.d.ts +1 -0
- package/dist/bundlers/vite/processed-css-assets.d.ts +1 -0
- package/dist/bundlers/vite/source-scan/css-entries.d.ts +1 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers.d.ts +2 -1
- package/dist/cli.js +18 -3
- package/dist/cli.mjs +16 -1
- package/dist/{context-D75pwtBW.js → context-BziwyWy1.js} +56 -9
- package/dist/{context-B07Vf584.mjs → context-rrYZuUBU.mjs} +48 -7
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/css-macro/auto.d.ts +1 -1
- package/dist/css-macro/index.d.ts +2 -1
- package/dist/css-macro.mjs +1 -1
- package/dist/{defaults-BhE26nSw.mjs → defaults-9B6aMyZb.mjs} +2 -2
- package/dist/{defaults-DQhgnnn-.js → defaults-nsf4VNMX.js} +2 -2
- package/dist/defaults.d.ts +1 -1
- package/dist/defaults.js +1 -1
- package/dist/defaults.mjs +1 -1
- package/dist/framework/platform.d.ts +2 -0
- package/dist/{generator-DNs6ekoC.mjs → generator-24-HgU9F.mjs} +5 -3
- package/dist/{generator-CV_0irKO.js → generator-CilgHtxb.js} +5 -3
- package/dist/generator.js +2 -2
- package/dist/generator.mjs +2 -2
- package/dist/{gulp-B_u8NjQL.js → gulp-CuVsZdO9.js} +7 -6
- package/dist/{gulp-aQMZ0M7c.mjs → gulp-ygWfmOqh.mjs} +4 -4
- package/dist/gulp.js +1 -1
- package/dist/gulp.mjs +1 -1
- package/dist/{hmr-timing-DOoHun3i.js → hmr-timing-BKdCeIrn.js} +244 -229
- package/dist/{hmr-timing-DLYQTCDb.mjs → hmr-timing-Dh_nn3w5.mjs} +244 -211
- package/dist/index.js +4 -4
- package/dist/index.mjs +4 -4
- package/dist/js/js-string-escape.d.ts +1 -0
- package/dist/postcss.js +2 -2
- package/dist/postcss.mjs +2 -2
- package/dist/presets.js +2 -2
- package/dist/presets.mjs +2 -2
- package/dist/rspack.js +1 -1
- package/dist/rspack.mjs +1 -1
- package/dist/{source-candidate-scan-signature-pS87mdHZ.mjs → source-candidate-scan-signature-DATRnS1X.mjs} +165 -8
- package/dist/{source-candidate-scan-signature-DzwebZrf.js → source-candidate-scan-signature-DIj9m4wB.js} +177 -7
- package/dist/style-injector/internal.d.ts +7 -0
- package/dist/style-injector/options.d.ts +25 -0
- package/dist/tailwindcss/v4/preflight.d.ts +4 -0
- package/dist/tailwindcss/v4-engine/css-macro-source.d.ts +2 -0
- package/dist/{tailwindcss-BSCvrs1p.js → tailwindcss-BwoNQ3t8.js} +56 -16
- package/dist/{tailwindcss-BwV3_Ryc.mjs → tailwindcss-C-uM4rB8.mjs} +51 -17
- package/dist/{transform-Clj7R818.mjs → transform-DHLemtaX.mjs} +1 -1
- package/dist/{transform-fin-OTVD.js → transform-KLD1tJdb.js} +1 -1
- package/dist/typedoc.export.d.ts +1 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/user-defined-options/general.d.ts +2 -0
- package/dist/{v4-engine-BklH3CpJ.mjs → v4-engine-BuuYDXt1.mjs} +54 -114
- package/dist/{v4-engine-CKbS27-o.js → v4-engine-CKtsdKxK.js} +57 -111
- package/dist/{vite-CkVMSDDp.js → vite-Yp14HNyS.js} +310 -78
- package/dist/{vite-5Wn0PIzJ.mjs → vite-cH0tTMHc.mjs} +308 -76
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.js +363 -272
- package/dist/{webpack-DEag6ueE.mjs → webpack-DBhmJ-_P.mjs} +107 -20
- package/dist/{webpack-hvSFaicc.js → webpack-DN3tgLbF.js} +107 -20
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +16 -5
- package/dist/auto-Ba6hDrse.mjs +0 -13
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { resolveImplicitAppTypeFromViteRoot } from "./framework.mjs";
|
|
2
|
-
import { C as hasTailwindRootDirectives, D as normalizeTailwindSourceForGenerator, F as hasTailwindGeneratedCssMarkers, G as getTailwindV4IncrementalGenerateCacheStats, O as parseImportRequest, S as hasTailwindNonRootGenerationDirectives, T as normalizeTailwindConfigDirectives, _ as resolveTailwindcssOptions, a as filterTailwindV4CssSourceRoots, b as hasLocalCssImport, d as normalizeCssEntries, f as findNearestPackageRoot, k as removeTailwindSourceDirectives, o as hasConfiguredTailwindV4CssRoots,
|
|
3
|
-
import { a as resolveGeneratorRuntimeBranch, c as shouldUseNativeAppCssBranch, i as normalizeWeappTailwindcssGeneratorOptions, s as shouldUseMiniProgramCssBranch } from "./generator-
|
|
2
|
+
import { C as hasTailwindRootDirectives, D as normalizeTailwindSourceForGenerator, F as hasTailwindGeneratedCssMarkers, G as getTailwindV4IncrementalGenerateCacheStats, O as parseImportRequest, S as hasTailwindNonRootGenerationDirectives, T as normalizeTailwindConfigDirectives, _ as resolveTailwindcssOptions, a as filterTailwindV4CssSourceRoots, b as hasLocalCssImport, ct as omitUndefined, d as normalizeCssEntries, f as findNearestPackageRoot, k as removeTailwindSourceDirectives, o as hasConfiguredTailwindV4CssRoots, rt as resolveTailwindV4CssSourceBase, s as upsertTailwindV4CssSource, st as filterUnsupportedMiniProgramTailwindV4Candidates, u as isTailwindV4CssEntry, w as hasTailwindSourceDirectives, x as hasTailwindApplyDirective } from "./v4-engine-BuuYDXt1.mjs";
|
|
3
|
+
import { a as resolveGeneratorRuntimeBranch, c as shouldUseNativeAppCssBranch, i as normalizeWeappTailwindcssGeneratorOptions, s as shouldUseMiniProgramCssBranch } from "./generator-24-HgU9F.mjs";
|
|
4
4
|
import { o as resolveUniUtsPlatform } from "./utils-DodxWHGz.mjs";
|
|
5
|
-
import { 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 { A as hasMiniProgramCssSpecificityPlaceholders, F as createCssTokenSourceMap, L as processCachedTask, M as stripMiniProgramCssSpecificityPlaceholders, N as annotateCssSourceTrace, P as createCssSourceTraceCacheSignature, _ as isPureLocalCssImportWrapper, a as isSourceCandidateRequest, d as validateCandidatesByGenerator, g as mergeMarkedUserLayerComponentsCss, h as extractMarkedUserLayerComponentsCss, m as runWithConcurrency, r as createSourceCandidateCollector, s as createBundleRuntimeClassSetManager, t as createHmrTimingRecorder } from "./hmr-timing-
|
|
8
|
-
import { A as isSourceStyleRequest, C as resolvePluginDisabledState, D as isHTMLRequest, E as isCSSRequest, M as normalizeOutputPathKey, O as normalizePath, P as toAbsoluteOutputPath, S as resolvePackageDir, T as formatPostcssSourceMap, _ as generateTailwindV4Css, a as createJsHashSalt, b as parseBundlerGeneratedCssMarkerBlocks, c as hasRuntimeAffectingSourceChanges, f as createBundleBuildState, g as createBundleModuleGraphOptions, h as applyLinkedResults, i as createCandidateSignature, j as stripRequestQuery, k as slash, l as summarizeStringDiff, m as createRuntimeAffectingSourceSignature, n as createScopedGeneratorCandidateSignature, o as createLinkedImpactSignature, p as updateBundleBuildState, r as createScopedGeneratorRuntime, s as getSnapshotHash, t as createSourceCandidateScanSignature, u as buildBundleSnapshot, v as createBundlerGeneratedCssMarker, w as cleanUrl, x as stripBundlerGeneratedCssMarkers, y as hasBundlerGeneratedCssMarker } from "./source-candidate-scan-signature-
|
|
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-rrYZuUBU.mjs";
|
|
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-C-uM4rB8.mjs";
|
|
7
|
+
import { A as hasMiniProgramCssSpecificityPlaceholders, F as createCssTokenSourceMap, L as processCachedTask, M as stripMiniProgramCssSpecificityPlaceholders, N as annotateCssSourceTrace, P as createCssSourceTraceCacheSignature, T as scoreTailwindV4CssSourceFileMatch, _ as isPureLocalCssImportWrapper, a as isSourceCandidateRequest, d as validateCandidatesByGenerator, g as mergeMarkedUserLayerComponentsCss, h as extractMarkedUserLayerComponentsCss, m as runWithConcurrency, r as createSourceCandidateCollector, s as createBundleRuntimeClassSetManager, t as createHmrTimingRecorder } from "./hmr-timing-Dh_nn3w5.mjs";
|
|
8
|
+
import { A as isSourceStyleRequest, C as resolvePluginDisabledState, D as isHTMLRequest, E as isCSSRequest, F as createBuiltinViteStyleInjectorPlugins, M as normalizeOutputPathKey, O as normalizePath, P as toAbsoluteOutputPath, S as resolvePackageDir, T as formatPostcssSourceMap, _ as generateTailwindV4Css, a as createJsHashSalt, b as parseBundlerGeneratedCssMarkerBlocks, c as hasRuntimeAffectingSourceChanges, f as createBundleBuildState, g as createBundleModuleGraphOptions, h as applyLinkedResults, i as createCandidateSignature, j as stripRequestQuery, k as slash, l as summarizeStringDiff, m as createRuntimeAffectingSourceSignature, n as createScopedGeneratorCandidateSignature, o as createLinkedImpactSignature, p as updateBundleBuildState, r as createScopedGeneratorRuntime, s as getSnapshotHash, t as createSourceCandidateScanSignature, u as buildBundleSnapshot, v as createBundlerGeneratedCssMarker, w as cleanUrl, x as stripBundlerGeneratedCssMarkers, y as hasBundlerGeneratedCssMarker } from "./source-candidate-scan-signature-DATRnS1X.mjs";
|
|
9
9
|
import { t as logger$1 } from "./logger-BNzxZbZj.mjs";
|
|
10
10
|
import fs, { existsSync, readFileSync, realpathSync } from "node:fs";
|
|
11
11
|
import path from "node:path";
|
|
12
12
|
import process$1 from "node:process";
|
|
13
13
|
import { splitCandidateTokens } from "@tailwindcss-mangle/engine";
|
|
14
|
-
import { containsCssAfterMinify, filterExistingCssRules, mergeCoveredCssRuleDeclarations, mergeMiniProgramPreflightRuleDeclarations, mergeMiniProgramThemeScopeRuleDeclarations, postcss, removeTailwindPostcssPlugins, resolveFilteredPostcssConfig } from "@weapp-tailwindcss/postcss";
|
|
14
|
+
import { compileCssMacroConditionalComments, containsCssAfterMinify, filterExistingCssRules, mergeCoveredCssRuleDeclarations, mergeMiniProgramPreflightRuleDeclarations, mergeMiniProgramThemeScopeRuleDeclarations, postcss, removeTailwindPostcssPlugins, resolveFilteredPostcssConfig, transformWebCssCompat, unwrapUnsupportedCascadeLayers } from "@weapp-tailwindcss/postcss";
|
|
15
15
|
import { LRUCache } from "lru-cache";
|
|
16
16
|
import { readFile } from "node:fs/promises";
|
|
17
17
|
import micromatch from "micromatch";
|
|
@@ -509,7 +509,7 @@ function resolveUniAppXStyleIsolationEnabled(root) {
|
|
|
509
509
|
//#region src/uni-app-x/vite.ts
|
|
510
510
|
let transformUVuePromise;
|
|
511
511
|
function loadTransformUVue() {
|
|
512
|
-
transformUVuePromise ?? (transformUVuePromise = import("./transform-
|
|
512
|
+
transformUVuePromise ?? (transformUVuePromise = import("./transform-DHLemtaX.mjs").then((mod) => mod.transformUVue));
|
|
513
513
|
return transformUVuePromise;
|
|
514
514
|
}
|
|
515
515
|
const preprocessorLangs = /* @__PURE__ */ new Set([
|
|
@@ -1119,12 +1119,14 @@ function createCssHandlerOptionsCache(options) {
|
|
|
1119
1119
|
const outputRoot = options.getOutputRoot?.();
|
|
1120
1120
|
const from = path.isAbsolute(file) ? file : outputRoot ? path.resolve(outputRoot, file) : file;
|
|
1121
1121
|
const extraOptions = options.getExtraOptions?.(file) ?? {};
|
|
1122
|
-
const
|
|
1122
|
+
const dynamicCssOptions = options.getDynamicCssOptions?.() ?? {};
|
|
1123
|
+
const cacheKey = `${majorVersion ?? "unknown"}:${appType ?? "unknown"}:${isMainChunk ? "1" : "0"}:${outputRoot ?? ""}:${file}:${JSON.stringify(extraOptions)}:${JSON.stringify(dynamicCssOptions)}`;
|
|
1123
1124
|
const cached = cssHandlerOptionsCache.get(cacheKey);
|
|
1124
1125
|
if (cached) return cached;
|
|
1125
1126
|
const created = {
|
|
1126
1127
|
isMainChunk,
|
|
1127
1128
|
...extraOptions,
|
|
1129
|
+
...dynamicCssOptions,
|
|
1128
1130
|
postcssOptions: { options: { from } },
|
|
1129
1131
|
majorVersion: normalizeStyleHandlerMajorVersion(majorVersion),
|
|
1130
1132
|
sourceOptions: { outputRoot }
|
|
@@ -1204,8 +1206,15 @@ function createMatchedCssSourceOutputResolver(options) {
|
|
|
1204
1206
|
const { assetSourceFile, file, originalFileNames, resolveOutputFileFromMatchedCssSource } = options;
|
|
1205
1207
|
return (sourceFile) => {
|
|
1206
1208
|
if (!sourceFile) return;
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
+
const cleanAssetSourceFile = assetSourceFile.replace(/[?#].*$/, "");
|
|
1210
|
+
const cleanSourceFile = sourceFile.replace(/[?#].*$/, "");
|
|
1211
|
+
const sourceHasQuery = cleanSourceFile !== sourceFile;
|
|
1212
|
+
const resolvedSourceOutputFile = resolveOutputFileFromMatchedCssSource(sourceFile);
|
|
1213
|
+
if (normalizeOutputPathKey(cleanAssetSourceFile) === normalizeOutputPathKey(cleanSourceFile) || originalFileNames?.some((originalFile) => normalizeOutputPathKey(originalFile.replace(/[?#].*$/, "")) === normalizeOutputPathKey(cleanSourceFile))) {
|
|
1214
|
+
if (!sourceHasQuery && normalizeOutputPathKey(cleanAssetSourceFile) === normalizeOutputPathKey(cleanSourceFile) && typeof resolvedSourceOutputFile === "string" && normalizeOutputPathKey(resolvedSourceOutputFile) !== normalizeOutputPathKey(file)) return resolvedSourceOutputFile;
|
|
1215
|
+
return file;
|
|
1216
|
+
}
|
|
1217
|
+
return resolvedSourceOutputFile;
|
|
1209
1218
|
};
|
|
1210
1219
|
}
|
|
1211
1220
|
function hasViteProcessedCssResultForSource(sourceFile, getViteProcessedCssAssetResults) {
|
|
@@ -1227,7 +1236,7 @@ function applyCssResultToBundle(options) {
|
|
|
1227
1236
|
const replayAsset = emitOrReplayCssAsset(outputFile, source);
|
|
1228
1237
|
if (replayAsset) bundle[outputFile] = replayAsset;
|
|
1229
1238
|
}
|
|
1230
|
-
originalSource.source = importShellSource ??
|
|
1239
|
+
originalSource.source = importShellSource ?? "";
|
|
1231
1240
|
return;
|
|
1232
1241
|
}
|
|
1233
1242
|
const existingOutput = bundle[outputFile];
|
|
@@ -1913,8 +1922,14 @@ function resolveSourceStyleSourceFromOutputFile(outputFile, snapshot, outputRoot
|
|
|
1913
1922
|
//#endregion
|
|
1914
1923
|
//#region src/bundlers/vite/generate-bundle/subpackages.ts
|
|
1915
1924
|
function readBundleAssetSource(output) {
|
|
1916
|
-
if (output.type !== "asset") return;
|
|
1917
|
-
|
|
1925
|
+
if ("type" in output && output.type !== "asset") return;
|
|
1926
|
+
const source = output.source;
|
|
1927
|
+
if (typeof source === "string") return source;
|
|
1928
|
+
if (typeof source === "function") {
|
|
1929
|
+
const value = source.call(output);
|
|
1930
|
+
return typeof value === "string" ? value : value?.toString();
|
|
1931
|
+
}
|
|
1932
|
+
if (source != null && typeof source.toString === "function") return source.toString();
|
|
1918
1933
|
}
|
|
1919
1934
|
function normalizePackageRoot(root) {
|
|
1920
1935
|
return normalizeOutputPathKey(root).replace(/\/+$/, "");
|
|
@@ -2127,6 +2142,7 @@ function shouldInjectViteProcessedCssResult(opts, targetFile, sourceFile, option
|
|
|
2127
2142
|
if (options.injectIntoMain === true) return isRootStyleOutputFile(targetFile) || typeof options.outputFile === "string" && normalizeOutputPathKey(options.outputFile) === normalizeOutputPathKey(targetFile);
|
|
2128
2143
|
if (options.injectIntoMain === false) return false;
|
|
2129
2144
|
const targetFileKey = normalizeOutputPathKey(targetFile);
|
|
2145
|
+
if (typeof options.outputFile === "string" && normalizeOutputPathKey(options.outputFile) === targetFileKey) return true;
|
|
2130
2146
|
return normalizeOutputPathKey(sourceFile) !== targetFileKey && (opts.mainCssChunkMatcher(sourceFile, opts.appType) || typeof options.outputFile === "string" && normalizeOutputPathKey(options.outputFile) !== targetFileKey && opts.mainCssChunkMatcher(options.outputFile, opts.appType));
|
|
2131
2147
|
}
|
|
2132
2148
|
function shouldReplayViteProcessedCssIntoMainCss(opts, file, sourceFile, outputFile, subpackageRoots) {
|
|
@@ -2162,7 +2178,7 @@ function resolvePreservedImportShellInjectionTarget(opts, bundle, file, css) {
|
|
|
2162
2178
|
}
|
|
2163
2179
|
function shouldUseCssAssetAsMainInjectionTarget(opts, file, records) {
|
|
2164
2180
|
const fileKey = normalizeOutputPathKey(file);
|
|
2165
|
-
if (!isRootStyleOutputFile(file) && records.some((record) => typeof record.outputFile === "string" && normalizeOutputPathKey(record.outputFile) === fileKey)) return
|
|
2181
|
+
if (!isRootStyleOutputFile(file) && records.some((record) => typeof record.outputFile === "string" && normalizeOutputPathKey(record.outputFile) === fileKey)) return true;
|
|
2166
2182
|
if (!isRootStyleOutputFile(file)) return records.some((record) => record.injectIntoMain === true && typeof record.outputFile === "string" && normalizeOutputPathKey(record.outputFile) === fileKey);
|
|
2167
2183
|
if (records.some((record) => {
|
|
2168
2184
|
if (record.injectIntoMain !== true) return false;
|
|
@@ -2210,6 +2226,12 @@ function collectBundleAssetFiles(bundle) {
|
|
|
2210
2226
|
}
|
|
2211
2227
|
return files;
|
|
2212
2228
|
}
|
|
2229
|
+
function findBundleAssetByOutputFile(bundle, file) {
|
|
2230
|
+
const fileKey = normalizeOutputPathKey(file);
|
|
2231
|
+
return Object.entries(bundle).find(([bundleFile, output]) => {
|
|
2232
|
+
return output.type === "asset" && normalizeOutputPathKey(getAssetFile$1(bundleFile, output)) === fileKey;
|
|
2233
|
+
})?.[1];
|
|
2234
|
+
}
|
|
2213
2235
|
function isCssImportOnlyBundleAsset(bundle, file, css) {
|
|
2214
2236
|
const importedStyleFiles = collectImportedStyleFiles(css, file);
|
|
2215
2237
|
if (importedStyleFiles.size === 0) return false;
|
|
@@ -2229,6 +2251,13 @@ function isCoveredViteGeneratedSourceAsset(file, existingAssetFiles, resolveVite
|
|
|
2229
2251
|
const resolvedOutputFile = normalizeOutputPathKey(resolveViteProcessedCssOutputFile?.(file) ?? file);
|
|
2230
2252
|
return resolvedOutputFile !== normalizeOutputPathKey(file) && existingAssetFiles.has(resolvedOutputFile);
|
|
2231
2253
|
}
|
|
2254
|
+
function resolveViteGeneratedCssMarkerOutputFile(file, markerFile, existingAssetFiles, resolveViteProcessedCssOutputFile) {
|
|
2255
|
+
const resolvedFromFile = normalizeOutputPathKey(resolveViteProcessedCssOutputFile?.(file) ?? file);
|
|
2256
|
+
if (!markerFile) return resolvedFromFile;
|
|
2257
|
+
const resolvedFromMarker = normalizeOutputPathKey(resolveViteProcessedCssOutputFile?.(markerFile) ?? markerFile);
|
|
2258
|
+
if (resolvedFromMarker !== resolvedFromFile && existingAssetFiles.has(resolvedFromMarker)) return resolvedFromMarker;
|
|
2259
|
+
return resolvedFromFile;
|
|
2260
|
+
}
|
|
2232
2261
|
function isSourceRootPrefixedOutputFile(file, outputFile) {
|
|
2233
2262
|
const fileKey = normalizeOutputPathKey(file);
|
|
2234
2263
|
const outputFileKey = normalizeOutputPathKey(outputFile);
|
|
@@ -2245,10 +2274,30 @@ function collectViteProcessedCssAssetResults(bundle, options) {
|
|
|
2245
2274
|
let nextCss = resolveViteProcessedCssAssetSource(file, rawSource, options.resolveViteProcessedCssOutputFile);
|
|
2246
2275
|
const singleMarkerFile = collectSingleViteGeneratedCssMarkerFile(rawSource);
|
|
2247
2276
|
if (singleMarkerFile && (options.subpackageRoots == null || !isSubpackageOutputFile(file, options.subpackageRoots)) && shouldFilterRootGeneratedCssMarkerForScopedAsset(file, singleMarkerFile, options.resolveViteProcessedCssOutputFile)) nextCss = removeCssCoveredByRootStyleBundleSources(bundle, file, nextCss);
|
|
2277
|
+
nextCss = options.transformCss?.(nextCss, file) ?? nextCss;
|
|
2248
2278
|
if (nextCss !== rawSource) output.source = nextCss;
|
|
2249
2279
|
options.markCssAssetProcessed?.(output, file);
|
|
2250
2280
|
options.recordCssAssetResult?.(file, nextCss);
|
|
2251
|
-
const resolvedOutputFile = options.resolveViteProcessedCssOutputFile
|
|
2281
|
+
const resolvedOutputFile = resolveViteGeneratedCssMarkerOutputFile(file, singleMarkerFile, existingAssetFiles, options.resolveViteProcessedCssOutputFile);
|
|
2282
|
+
if (singleMarkerFile && normalizeOutputPathKey(resolvedOutputFile) !== normalizeOutputPathKey(file) && !isRootStyleOutputFile(resolvedOutputFile) && existingAssetFiles.has(normalizeOutputPathKey(resolvedOutputFile))) {
|
|
2283
|
+
const targetAsset = findBundleAssetByOutputFile(bundle, resolvedOutputFile);
|
|
2284
|
+
if (targetAsset) {
|
|
2285
|
+
const targetRawSource = readAssetSource$2(targetAsset);
|
|
2286
|
+
const targetNextCss = appendCss$1(targetRawSource, filterExistingCssRules(targetRawSource, nextCss).trim());
|
|
2287
|
+
if (targetNextCss !== targetRawSource) {
|
|
2288
|
+
targetAsset.source = targetNextCss;
|
|
2289
|
+
options.markCssAssetProcessed?.(targetAsset, resolvedOutputFile);
|
|
2290
|
+
options.recordCssAssetResult?.(resolvedOutputFile, targetNextCss);
|
|
2291
|
+
}
|
|
2292
|
+
clearAssetSource(output);
|
|
2293
|
+
options.recordCssAssetResult?.(file, "");
|
|
2294
|
+
options.recordViteProcessedCssAssetResult?.(resolvedOutputFile, targetNextCss, { outputFile: resolvedOutputFile });
|
|
2295
|
+
if (isCoveredViteGeneratedSourceAsset(file, existingAssetFiles, options.resolveViteProcessedCssOutputFile)) delete bundle[bundleFile];
|
|
2296
|
+
options.debug?.("move vite-generated css asset by marker source: %s -> %s bytes=%d", file, resolvedOutputFile, nextCss.length);
|
|
2297
|
+
collected++;
|
|
2298
|
+
continue;
|
|
2299
|
+
}
|
|
2300
|
+
}
|
|
2252
2301
|
const shouldReplayIntoMainCss = options.opts != null && shouldReplayViteProcessedCssIntoMainCss(options.opts, file, singleMarkerFile, resolvedOutputFile, options.subpackageRoots);
|
|
2253
2302
|
options.recordViteProcessedCssAssetResult?.(file, nextCss, {
|
|
2254
2303
|
injectIntoMain: shouldReplayIntoMainCss || void 0,
|
|
@@ -3165,13 +3214,15 @@ function createRememberedCssRuntimeSignature(cssRuntimeSignature, cssRuntimeAffe
|
|
|
3165
3214
|
function normalizeRememberedSourceIdentity(file) {
|
|
3166
3215
|
return normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
3167
3216
|
}
|
|
3168
|
-
function selectBestRememberedCssSourceMatches(sources, outputFile, outputRoot, sourceRoot) {
|
|
3169
|
-
|
|
3217
|
+
function selectBestRememberedCssSourceMatches(sources, outputFile, outputRoot, sourceRoot, options = {}) {
|
|
3218
|
+
const minimumScore = options.minimumScore ?? (options.requirePositiveScore ? 1 : 0);
|
|
3170
3219
|
const scoredMatches = sources.map((remembered) => ({
|
|
3171
3220
|
remembered,
|
|
3172
3221
|
score: Math.max(scoreMatchingStyleFileBase(outputFile, remembered.sourceFile, outputRoot, sourceRoot), scoreMatchingStyleFileBase(outputFile, remembered.outputFile, outputRoot, sourceRoot))
|
|
3173
|
-
})).filter((match) => match.score > 0).sort((a, b) => b.score - a.score);
|
|
3222
|
+
})).filter((match) => match.score >= minimumScore && match.score > 0).sort((a, b) => b.score - a.score);
|
|
3174
3223
|
const bestScore = scoredMatches[0]?.score;
|
|
3224
|
+
if (!bestScore && minimumScore > 0) return [];
|
|
3225
|
+
if (sources.length <= 1) return sources;
|
|
3175
3226
|
return bestScore ? scoredMatches.filter((match) => match.score === bestScore).map((match) => match.remembered) : sources;
|
|
3176
3227
|
}
|
|
3177
3228
|
function findRememberedCssSources(sources, outputFile, file, originalSource, outputRoot, sourceRoot) {
|
|
@@ -3189,11 +3240,16 @@ function findRememberedCssSources(sources, outputFile, file, originalSource, out
|
|
|
3189
3240
|
...originalSource.originalFileNames ?? []
|
|
3190
3241
|
].filter((item) => typeof item === "string" && item.length > 0);
|
|
3191
3242
|
const sourceMatched = rememberedSources.filter((remembered) => originalFiles.some((originalFile) => normalizeRememberedSourceIdentity(remembered.sourceFile) === normalizeRememberedSourceIdentity(originalFile)));
|
|
3192
|
-
if (sourceMatched.length > 0)
|
|
3243
|
+
if (sourceMatched.length > 0) {
|
|
3244
|
+
const scoredSourceMatched = selectBestRememberedCssSourceMatches(sourceMatched, outputFile, outputRoot, sourceRoot, { requirePositiveScore: true });
|
|
3245
|
+
if (scoredSourceMatched.length > 0) return scoredSourceMatched;
|
|
3246
|
+
}
|
|
3193
3247
|
const outputMatched = rememberedSources.filter((remembered) => normalizeOutputPathKey(remembered.outputFile) === normalizeOutputPathKey(outputFile));
|
|
3194
3248
|
if (outputMatched.length > 0) return outputMatched;
|
|
3195
3249
|
if (!hasBundlerGeneratedCssMarker(source) && !hasTailwindGenerationSource(source)) return [];
|
|
3196
3250
|
const scoredMatches = selectBestRememberedCssSourceMatches(rememberedSources, outputFile, outputRoot, sourceRoot);
|
|
3251
|
+
const strongScoredMatches = selectBestRememberedCssSourceMatches(rememberedSources, outputFile, outputRoot, sourceRoot, { minimumScore: 1e5 });
|
|
3252
|
+
if (strongScoredMatches.length > 0 && strongScoredMatches.length < rememberedSources.length) return strongScoredMatches;
|
|
3197
3253
|
return scoredMatches.length === rememberedSources.length ? [] : scoredMatches;
|
|
3198
3254
|
}
|
|
3199
3255
|
function mergeRememberedCssSources(sources, outputFile) {
|
|
@@ -3545,6 +3601,14 @@ function resolveCurrentSourceCandidateSource(options) {
|
|
|
3545
3601
|
}
|
|
3546
3602
|
//#endregion
|
|
3547
3603
|
//#region src/bundlers/vite/generate-bundle/tailwind-v4-css-source.ts
|
|
3604
|
+
function createStableTextSignature(input) {
|
|
3605
|
+
let hash = 2166136261;
|
|
3606
|
+
for (let i = 0; i < input.length; i++) {
|
|
3607
|
+
hash ^= input.charCodeAt(i);
|
|
3608
|
+
hash = Math.imul(hash, 16777619);
|
|
3609
|
+
}
|
|
3610
|
+
return (hash >>> 0).toString(36);
|
|
3611
|
+
}
|
|
3548
3612
|
function collectTailwindV4SourceFingerprint(source) {
|
|
3549
3613
|
const tokens = /* @__PURE__ */ new Set();
|
|
3550
3614
|
const add = (prefix, value) => {
|
|
@@ -3556,6 +3620,22 @@ function collectTailwindV4SourceFingerprint(source) {
|
|
|
3556
3620
|
add("config-request", configRequest.replace(/\\/g, "/"));
|
|
3557
3621
|
}
|
|
3558
3622
|
for (const match of source.matchAll(/@source\s+(not\s+)?(["'])(.+?)\2\s*;?/g)) add(match[1] ? "source:not" : "source", match[3]);
|
|
3623
|
+
for (const match of source.matchAll(/@plugin\s+(["'])(.+?)\1\s*(?:\{([\s\S]*?)\}|;)/g)) {
|
|
3624
|
+
const request = match[2];
|
|
3625
|
+
const optionBlock = match[3];
|
|
3626
|
+
add("plugin", request);
|
|
3627
|
+
add("plugin-request", request.replace(/\\/g, "/"));
|
|
3628
|
+
if (optionBlock !== void 0) add("plugin-options", `${request}:${createStableTextSignature(optionBlock)}`);
|
|
3629
|
+
}
|
|
3630
|
+
try {
|
|
3631
|
+
postcss.parse(source).walkAtRules("plugin", (rule) => {
|
|
3632
|
+
const request = /^(['"])(.+?)\1/.exec(rule.params.trim())?.[2];
|
|
3633
|
+
if (!request || !rule.nodes?.length) return;
|
|
3634
|
+
rule.walkDecls((decl) => {
|
|
3635
|
+
add("plugin-option", `${request}:${decl.prop}:${decl.value}`);
|
|
3636
|
+
});
|
|
3637
|
+
});
|
|
3638
|
+
} catch {}
|
|
3559
3639
|
for (const match of source.matchAll(/@custom-variant\s+([^{\s]+)/g)) add("custom-variant", match[1]);
|
|
3560
3640
|
for (const match of source.matchAll(/@(?:theme|utility|variant|layer)\s+([^{;\s]+)/g)) add("directive", match[1]);
|
|
3561
3641
|
for (const match of source.matchAll(/--[\w-]+(?=\s*:)/g)) add("theme-token", match[0]);
|
|
@@ -3571,16 +3651,24 @@ function scoreConfiguredTailwindV4SourceForRawSource(rawSource, entrySource) {
|
|
|
3571
3651
|
for (const token of entryTokens) if (rawTokens.has(token)) score += token.startsWith("config:") ? 100 : 1;
|
|
3572
3652
|
return score;
|
|
3573
3653
|
}
|
|
3574
|
-
function
|
|
3575
|
-
if (!file || !subpackageRoots) return;
|
|
3576
|
-
return [...subpackageRoots].find((root) => isSubpackageOutputFile(file, /* @__PURE__ */ new Set([root])));
|
|
3577
|
-
}
|
|
3578
|
-
function isSameSubpackageScope(outputFile, sourceFile, subpackageRoots) {
|
|
3579
|
-
return resolveSubpackageRootForFile(outputFile, subpackageRoots) === resolveSubpackageRootForFile(sourceFile, subpackageRoots);
|
|
3580
|
-
}
|
|
3581
|
-
function selectTailwindV4GenerationCssSourceForOutput(outputFile, entries, rawSource, subpackageRoots) {
|
|
3654
|
+
function selectTailwindV4GenerationCssSourceForOutput(outputFile, entries, rawSource, options = {}) {
|
|
3582
3655
|
const generationSources = entries.filter((entry) => hasTailwindGenerationSource(entry.source));
|
|
3583
3656
|
if (generationSources.length <= 1) return generationSources[0];
|
|
3657
|
+
const canMatchByOutputPath = Boolean(options.cwd || options.outputRoot || options.projectRoot);
|
|
3658
|
+
const selectByOutputPath = (candidates) => {
|
|
3659
|
+
if (!canMatchByOutputPath) return;
|
|
3660
|
+
const scoredSources = candidates.map((entry) => ({
|
|
3661
|
+
entry,
|
|
3662
|
+
score: scoreTailwindV4CssSourceFileMatch(outputFile, entry.file, {
|
|
3663
|
+
cwd: options.cwd,
|
|
3664
|
+
outputRoot: options.outputRoot,
|
|
3665
|
+
projectRoot: options.projectRoot
|
|
3666
|
+
})
|
|
3667
|
+
})).filter((item) => item.score > 0).sort((a, b) => b.score - a.score);
|
|
3668
|
+
const bestScore = scoredSources[0]?.score;
|
|
3669
|
+
const bestSources = bestScore ? scoredSources.filter((item) => item.score === bestScore) : [];
|
|
3670
|
+
return bestSources.length === 1 ? bestSources[0]?.entry : void 0;
|
|
3671
|
+
};
|
|
3584
3672
|
const selectByRawSourceFingerprint = (candidates) => {
|
|
3585
3673
|
const scoredSources = candidates.map((entry) => ({
|
|
3586
3674
|
entry,
|
|
@@ -3592,14 +3680,10 @@ function selectTailwindV4GenerationCssSourceForOutput(outputFile, entries, rawSo
|
|
|
3592
3680
|
};
|
|
3593
3681
|
const rawSourceMatched = selectByRawSourceFingerprint(generationSources);
|
|
3594
3682
|
if (rawSourceMatched) return rawSourceMatched;
|
|
3595
|
-
const
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
return sourceMatchesSubpackage && [...subpackageRoots].some((root) => isSubpackageOutputFile(outputFile, /* @__PURE__ */ new Set([root])) && isSubpackageOutputFile(entry.file, /* @__PURE__ */ new Set([root])));
|
|
3600
|
-
}) : generationSources;
|
|
3601
|
-
const explicitSources = scopedSources.filter((entry) => /@(?:config|source|plugin|custom-variant|theme|utility|variant|apply)\b/.test(entry.source));
|
|
3602
|
-
const candidates = explicitSources.length === 1 ? explicitSources : scopedSources;
|
|
3683
|
+
const explicitSources = generationSources.filter((entry) => /@(?:config|source|plugin|custom-variant|theme|utility|variant|apply)\b/.test(entry.source));
|
|
3684
|
+
const candidates = explicitSources.length === 1 ? explicitSources : generationSources;
|
|
3685
|
+
const outputPathMatched = selectByOutputPath(candidates);
|
|
3686
|
+
if (outputPathMatched) return outputPathMatched;
|
|
3603
3687
|
if (candidates.length === 1) return candidates[0];
|
|
3604
3688
|
return selectByRawSourceFingerprint(candidates);
|
|
3605
3689
|
}
|
|
@@ -3617,7 +3701,7 @@ function createTemporaryCssAssetSourceResolver(entries) {
|
|
|
3617
3701
|
const queuedEntries = entries.filter((entry) => {
|
|
3618
3702
|
const entryFile = normalizeCssSourceKey(entry.file);
|
|
3619
3703
|
const outputFile = normalizeCssSourceKey(entry.outputFile);
|
|
3620
|
-
if (
|
|
3704
|
+
if (outputFile === entryFile || !outputFile.includes("/") || seenEntryFiles.has(entryFile)) return false;
|
|
3621
3705
|
seenEntryFiles.add(entryFile);
|
|
3622
3706
|
return true;
|
|
3623
3707
|
});
|
|
@@ -3628,9 +3712,16 @@ function createTemporaryCssAssetSourceResolver(entries) {
|
|
|
3628
3712
|
if (!sourceFile) return;
|
|
3629
3713
|
usedEntryFiles.add(normalizeCssSourceKey(sourceFile));
|
|
3630
3714
|
},
|
|
3631
|
-
resolve(outputFile) {
|
|
3715
|
+
resolve(outputFile, rawSource) {
|
|
3632
3716
|
if (!isTemporaryCssAssetFile(outputFile)) return;
|
|
3633
|
-
const
|
|
3717
|
+
const availableEntries = queuedEntries.filter((item) => !usedEntryFiles.has(normalizeCssSourceKey(item.file)));
|
|
3718
|
+
const scoredEntries = rawSource ? availableEntries.map((entry) => ({
|
|
3719
|
+
entry,
|
|
3720
|
+
score: scoreConfiguredTailwindV4SourceForRawSource(rawSource, entry.source)
|
|
3721
|
+
})).filter((item) => item.score > 0).sort((a, b) => b.score - a.score) : [];
|
|
3722
|
+
const bestScore = scoredEntries[0]?.score;
|
|
3723
|
+
const bestEntries = bestScore ? scoredEntries.filter((item) => item.score === bestScore) : [];
|
|
3724
|
+
const entry = bestEntries.length === 1 ? bestEntries[0]?.entry : availableEntries.find((item) => hasTailwindGenerationSource(item.source));
|
|
3634
3725
|
if (!entry) return;
|
|
3635
3726
|
usedEntryFiles.add(normalizeCssSourceKey(entry.file));
|
|
3636
3727
|
return {
|
|
@@ -4046,7 +4137,7 @@ function createGenerateBundleHook(context) {
|
|
|
4046
4137
|
...[...runtimeLinkedCssFiles].filter((file) => !snapshot.sourceHashByFile.has(file)).map((file) => {
|
|
4047
4138
|
const outputFile = resolveViteCssPipelineOutputFile(file, opts, rootDir, isWebGeneratorTarget, shouldPreserveAppCssExtension, sourceRoot, defaultStyleOutputExtension, bundleFiles);
|
|
4048
4139
|
const inferredSourceStyle = resolveSourceStyleSourceFromOutputFile(outputFile, snapshot, outDir, sourceRoot, getCssSource, jsImportedCssFiles.has(file) ? getSourceCandidateSources : void 0, getConfiguredTailwindV4CssSourceEntries().map((entry) => [entry.file, entry.source]), debug);
|
|
4049
|
-
return inferredSourceStyle && currentSubpackageRoots
|
|
4140
|
+
return inferredSourceStyle && currentSubpackageRoots ? {
|
|
4050
4141
|
file: inferredSourceStyle.sourceFile,
|
|
4051
4142
|
outputFile,
|
|
4052
4143
|
source: inferredSourceStyle.rawSource
|
|
@@ -4057,6 +4148,14 @@ function createGenerateBundleHook(context) {
|
|
|
4057
4148
|
outputFile: remembered.outputFile,
|
|
4058
4149
|
source: remembered.rawSource
|
|
4059
4150
|
})),
|
|
4151
|
+
...getConfiguredTailwindV4CssSourceEntries().map((entry) => {
|
|
4152
|
+
const outputFile = resolveMatchedCssSourceOutputFile(entry.file);
|
|
4153
|
+
return outputFile ? {
|
|
4154
|
+
file: entry.file,
|
|
4155
|
+
outputFile,
|
|
4156
|
+
source: entry.source
|
|
4157
|
+
} : void 0;
|
|
4158
|
+
}).filter((entry) => entry != null),
|
|
4060
4159
|
...configuredTailwindV4CssSourceEntriesForScope.map((entry) => {
|
|
4061
4160
|
const outputFile = resolveMatchedCssSourceOutputFile(entry.file);
|
|
4062
4161
|
return outputFile && currentSubpackageRoots && isSubpackageOutputFile(outputFile, currentSubpackageRoots) ? {
|
|
@@ -4201,6 +4300,11 @@ function createGenerateBundleHook(context) {
|
|
|
4201
4300
|
if (rememberedCssSources.length > 0) rememberedCssSources = await Promise.all(rememberedCssSources.map(async (remembered) => {
|
|
4202
4301
|
return await refreshRememberedCssSource?.(remembered) ?? remembered;
|
|
4203
4302
|
}));
|
|
4303
|
+
rememberedCssSources = rememberedCssSources.filter((remembered) => {
|
|
4304
|
+
if (!configuredTailwindV4CssSourceFileKeysForScope.has(normalizeOutputPathKey(remembered.sourceFile.replace(/[?#].*$/, "")))) return true;
|
|
4305
|
+
const matchedOutputFile = resolveMatchedOutputFileForCurrentAsset(remembered.sourceFile);
|
|
4306
|
+
return !matchedOutputFile || normalizeOutputPathKey(matchedOutputFile) === normalizeOutputPathKey(outputFile);
|
|
4307
|
+
});
|
|
4204
4308
|
let hasUsableRememberedTailwindSource = rememberedCssSources.some((remembered) => hasTailwindGenerationSource(remembered.rawSource) && normalizeOutputPathKey(remembered.sourceFile.replace(/[?#].*$/, "")) !== normalizeOutputPathKey(file));
|
|
4205
4309
|
const inferredSfcStyleSource = await resolveSfcStyleSourceFromOutputFile(outputFile, snapshot, outDir, opts.tailwindcssBasedir, opts.cssMatcher, getSfcSource, debug);
|
|
4206
4310
|
if (inferredSfcStyleSource) {
|
|
@@ -4213,12 +4317,8 @@ function createGenerateBundleHook(context) {
|
|
|
4213
4317
|
hasUsableRememberedTailwindSource = false;
|
|
4214
4318
|
}
|
|
4215
4319
|
let outputCssHandlerOptions = getCssHandlerOptions(outputFile);
|
|
4216
|
-
if (currentSubpackageRoots && rememberedCssSources.length > 0 && rememberedCssSources.some((remembered) => configuredTailwindV4CssSourceFileKeysForScope.has(normalizeOutputPathKey(remembered.sourceFile.replace(/[?#].*$/, ""))) && !isSameSubpackageScope(outputFile, remembered.sourceFile, currentSubpackageRoots))) {
|
|
4217
|
-
rememberedCssSources = [];
|
|
4218
|
-
hasUsableRememberedTailwindSource = false;
|
|
4219
|
-
}
|
|
4220
4320
|
if (isTemporaryCssAssetFile(outputFile) && hasTailwindGenerationSource(rawSource)) {
|
|
4221
|
-
const resolvedTemporarySource = temporaryCssAssetSourceResolver.resolve(outputFile);
|
|
4321
|
+
const resolvedTemporarySource = temporaryCssAssetSourceResolver.resolve(outputFile, rawSource);
|
|
4222
4322
|
if (resolvedTemporarySource) {
|
|
4223
4323
|
outputFile = resolveMatchedOutputFileForCurrentAsset(resolvedTemporarySource.sourceFile) ?? resolvedTemporarySource.outputFile;
|
|
4224
4324
|
activeViteCssCacheFiles.add(normalizeViteCssCacheKey(outputFile));
|
|
@@ -4250,7 +4350,7 @@ function createGenerateBundleHook(context) {
|
|
|
4250
4350
|
outputFile
|
|
4251
4351
|
}];
|
|
4252
4352
|
} else if (isTemporaryCssAssetFile(outputFile) && configuredTailwindV4CssSourceEntries.length > 1) {
|
|
4253
|
-
const resolvedTemporarySource = temporaryCssAssetSourceResolver.resolve(outputFile);
|
|
4353
|
+
const resolvedTemporarySource = temporaryCssAssetSourceResolver.resolve(outputFile, rawSource);
|
|
4254
4354
|
if (resolvedTemporarySource) {
|
|
4255
4355
|
outputFile = resolveMatchedOutputFileForCurrentAsset(resolvedTemporarySource.sourceFile) ?? resolvedTemporarySource.outputFile;
|
|
4256
4356
|
activeViteCssCacheFiles.add(normalizeViteCssCacheKey(outputFile));
|
|
@@ -4270,7 +4370,11 @@ function createGenerateBundleHook(context) {
|
|
|
4270
4370
|
}
|
|
4271
4371
|
} else if (hasTailwindGenerationSource(rawSource) && (originalSource.originalFileNames?.length ?? 0) === 0) {
|
|
4272
4372
|
const availableConfiguredTailwindV4CssSourceEntries = configuredTailwindV4CssSourceEntries.filter((entry) => !usedConfiguredTailwindV4CssSourceFiles.has(normalizeOutputPathKey(entry.file)));
|
|
4273
|
-
const configuredGenerationSource = selectTailwindV4GenerationCssSourceForOutput(outputFile, availableConfiguredTailwindV4CssSourceEntries, rawSource,
|
|
4373
|
+
const configuredGenerationSource = selectTailwindV4GenerationCssSourceForOutput(outputFile, availableConfiguredTailwindV4CssSourceEntries, rawSource, {
|
|
4374
|
+
cwd: opts.tailwindcssBasedir,
|
|
4375
|
+
outputRoot: outDir,
|
|
4376
|
+
projectRoot: sourceRoot ?? rootDir
|
|
4377
|
+
});
|
|
4274
4378
|
if (configuredGenerationSource && !hasViteProcessedCssResultForSource(configuredGenerationSource.file, getViteProcessedCssAssetResults)) {
|
|
4275
4379
|
outputFile = resolveMatchedOutputFileForCurrentAsset(configuredGenerationSource.file) ?? outputFile;
|
|
4276
4380
|
activeViteCssCacheFiles.add(normalizeViteCssCacheKey(outputFile));
|
|
@@ -4327,12 +4431,13 @@ function createGenerateBundleHook(context) {
|
|
|
4327
4431
|
...getCssHandlerOptions(generatorSourceFile),
|
|
4328
4432
|
isMainChunk: resolvedFromTemporaryCssAsset ? false : outputCssHandlerOptions.isMainChunk
|
|
4329
4433
|
} : getCssHandlerOptions(file);
|
|
4434
|
+
const generatorCssEntries = configuredTailwindV4CssSourceFileKeysForScope.has(normalizeOutputPathKey(generatorSourceFile.replace(/[?#].*$/, ""))) ? [generatorSourceFile] : opts.cssEntries;
|
|
4330
4435
|
const generatorCssHandlerOptions = {
|
|
4331
4436
|
...cssHandlerOptions,
|
|
4332
4437
|
sourceOptions: {
|
|
4333
4438
|
...cssHandlerOptions.sourceOptions ?? {},
|
|
4334
4439
|
sourceFile: generatorSourceFile,
|
|
4335
|
-
cssEntries:
|
|
4440
|
+
cssEntries: generatorCssEntries
|
|
4336
4441
|
}
|
|
4337
4442
|
};
|
|
4338
4443
|
const scopedSourceCandidateGetter = createScopedSourceCandidateGetter(outputFile, generatorCssHandlerOptions);
|
|
@@ -4636,6 +4741,7 @@ function registerGeneratorDependencies(ctx, dependencies) {
|
|
|
4636
4741
|
function createCssHandlerOptions(opts, majorVersion, file) {
|
|
4637
4742
|
return {
|
|
4638
4743
|
...resolveUniAppXNativeCssHandlerOptions(opts),
|
|
4744
|
+
cssPreflight: opts.cssPreflight,
|
|
4639
4745
|
isMainChunk: opts.mainCssChunkMatcher(file, opts.appType),
|
|
4640
4746
|
postcssOptions: { options: { from: file } },
|
|
4641
4747
|
...normalizeStyleHandlerMajorVersion(majorVersion) === void 0 ? {} : { majorVersion: 4 }
|
|
@@ -4659,6 +4765,9 @@ function shouldFinalizeProcessedCssAsset(opts, file) {
|
|
|
4659
4765
|
function collectViteProcessedCssSources(getViteProcessedCssAssetResults) {
|
|
4660
4766
|
return [...getViteProcessedCssAssetResults?.() ?? []].map(([, record]) => typeof record === "string" ? record : record.css);
|
|
4661
4767
|
}
|
|
4768
|
+
function finalizeWebCss(css, enabled, webCompat) {
|
|
4769
|
+
return enabled ? transformWebCssCompat(css, webCompat) : css;
|
|
4770
|
+
}
|
|
4662
4771
|
function createViteCssFinalizerOutputPlugin(context) {
|
|
4663
4772
|
return {
|
|
4664
4773
|
name: "weapp-tailwindcss:adaptor:css-finalizer",
|
|
@@ -4669,13 +4778,14 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
4669
4778
|
const { opts, runtimeState, ensureRuntimeClassSet, isCssAssetProcessed, markCssAssetProcessed, debug, getResolvedConfig, recordCssAssetResult, recordViteProcessedCssAssetResult, getViteProcessedCssAssetResults, getRecordedGeneratorCandidates, getSourceCandidates, getSourceCandidatesForEntries, getSourceCandidateSourcesForEntries, waitForSourceCandidateSyncs, rememberMainCssSource, getRememberedMainCssSource, isViteProcessedCssAsset } = context;
|
|
4670
4779
|
const resolvedConfig = getResolvedConfig();
|
|
4671
4780
|
const uniUtsPlatform = resolveUniUtsPlatform();
|
|
4672
|
-
const
|
|
4781
|
+
const generatorOptions = normalizeWeappTailwindcssGeneratorOptions(opts.generator, {
|
|
4673
4782
|
appType: opts.appType,
|
|
4674
4783
|
platform: opts.cssOptions?.platform ?? opts.platform,
|
|
4675
4784
|
tailwindcssMajorVersion: runtimeState.tailwindRuntime.majorVersion,
|
|
4676
4785
|
uniAppX: opts.uniAppX,
|
|
4677
4786
|
uniUtsPlatform
|
|
4678
|
-
})
|
|
4787
|
+
});
|
|
4788
|
+
const generatorBranch = resolveGeneratorRuntimeBranch(generatorOptions, {
|
|
4679
4789
|
appType: opts.appType,
|
|
4680
4790
|
platform: opts.cssOptions?.platform ?? opts.platform,
|
|
4681
4791
|
tailwindcssMajorVersion: runtimeState.tailwindRuntime.majorVersion,
|
|
@@ -4702,6 +4812,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
4702
4812
|
recordCssAssetResult,
|
|
4703
4813
|
recordViteProcessedCssAssetResult,
|
|
4704
4814
|
resolveViteProcessedCssOutputFile: (file) => resolveViteCssPipelineOutputFile(file, opts, rootDir, isWebGeneratorTarget, isNativeAppStyleTarget, sourceRoot, resolveMiniProgramStyleOutputExtension({ files: Object.keys(bundle) }), Object.keys(bundle)),
|
|
4815
|
+
transformCss: (css) => finalizeWebCss(css, generatorBranch.isWeb, generatorOptions.webCompat),
|
|
4705
4816
|
debug
|
|
4706
4817
|
});
|
|
4707
4818
|
};
|
|
@@ -4774,7 +4885,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
4774
4885
|
const file = output.fileName || bundleFile;
|
|
4775
4886
|
const rawSource = output.source.toString();
|
|
4776
4887
|
if (isViteProcessedCssAsset?.(output, file)) {
|
|
4777
|
-
const nextCss = annotateCss(stripBundlerGeneratedCssMarkers(rawSource));
|
|
4888
|
+
const nextCss = annotateCss(finalizeWebCss(stripBundlerGeneratedCssMarkers(rawSource), generatorBranch.isWeb, generatorOptions.webCompat));
|
|
4778
4889
|
output.source = nextCss;
|
|
4779
4890
|
markCssAssetProcessed(output, file);
|
|
4780
4891
|
recordCssAssetResult?.(file, nextCss);
|
|
@@ -4808,7 +4919,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
4808
4919
|
styleHandler: opts.styleHandler,
|
|
4809
4920
|
debug
|
|
4810
4921
|
}) : void 0;
|
|
4811
|
-
const nextCss = annotateCss(generated?.css ?? (generatorBranch.isWeb ? rawSource : (await opts.styleHandler(rawSource, cssHandlerOptions)).css));
|
|
4922
|
+
const nextCss = annotateCss(generated?.css ?? (generatorBranch.isWeb ? finalizeWebCss(rawSource, true, generatorOptions.webCompat) : (await opts.styleHandler(rawSource, cssHandlerOptions)).css));
|
|
4812
4923
|
if (generated) {
|
|
4813
4924
|
registerGeneratorDependencies(this, generated.dependencies);
|
|
4814
4925
|
debug("css finalizer generated result: %s bytes=%d", file, nextCss.length);
|
|
@@ -5111,6 +5222,22 @@ function resolveHotTailwindCssModules(ctx, tailwindRootCssModuleIds) {
|
|
|
5111
5222
|
}
|
|
5112
5223
|
return modules;
|
|
5113
5224
|
}
|
|
5225
|
+
function resolveHotSourceModules(ctx) {
|
|
5226
|
+
const modules = [];
|
|
5227
|
+
const seenModules = /* @__PURE__ */ new Set();
|
|
5228
|
+
const collectModule = (mod) => {
|
|
5229
|
+
if (mod == null || seenModules.has(mod)) return;
|
|
5230
|
+
if (isSourceStyleRequest(mod.id ?? mod.url)) return;
|
|
5231
|
+
seenModules.add(mod);
|
|
5232
|
+
modules.push(mod);
|
|
5233
|
+
};
|
|
5234
|
+
for (const mod of ctx.modules) collectModule(mod);
|
|
5235
|
+
for (const mod of ctx.server.moduleGraph.getModulesByFile(ctx.file) ?? []) collectModule(mod);
|
|
5236
|
+
for (const mod of ctx.server.moduleGraph.getModulesByFile(cleanUrl(ctx.file)) ?? []) collectModule(mod);
|
|
5237
|
+
collectModule(ctx.server.moduleGraph.getModuleById?.(ctx.file));
|
|
5238
|
+
collectModule(ctx.server.moduleGraph.getModuleById?.(cleanUrl(ctx.file)));
|
|
5239
|
+
return modules;
|
|
5240
|
+
}
|
|
5114
5241
|
function resolveModuleHotUrl(mod) {
|
|
5115
5242
|
if (typeof mod.url === "string" && mod.url.length > 0) return mod.url;
|
|
5116
5243
|
if (typeof mod.id === "string" && mod.id.startsWith("/")) return mod.id;
|
|
@@ -5579,6 +5706,30 @@ const weappTailwindcssPackageDir = resolvePackageDir("weapp-tailwindcss");
|
|
|
5579
5706
|
const weappTailwindcssDirPosix = slash(weappTailwindcssPackageDir);
|
|
5580
5707
|
const SOURCE_CANDIDATE_SCAN_CACHE_MAX = 8;
|
|
5581
5708
|
const sourceCandidateScanSnapshotCache = new LRUCache({ max: SOURCE_CANDIDATE_SCAN_CACHE_MAX });
|
|
5709
|
+
const ENV_PLATFORM_KEYS = [
|
|
5710
|
+
"UNI_PLATFORM",
|
|
5711
|
+
"UNI_UTS_PLATFORM",
|
|
5712
|
+
"TARO_ENV",
|
|
5713
|
+
"MPX_CURRENT_TARGET_MODE",
|
|
5714
|
+
"MPX_CLI_MODE"
|
|
5715
|
+
];
|
|
5716
|
+
function sameStringList(first, second) {
|
|
5717
|
+
if (first === second) return true;
|
|
5718
|
+
if (!first || !second || first.length !== second.length) return false;
|
|
5719
|
+
return first.every((item, index) => item === second[index]);
|
|
5720
|
+
}
|
|
5721
|
+
function normalizeViteStylePlatform(value, appType) {
|
|
5722
|
+
return normalizeFrameworkStylePlatform(value, appType);
|
|
5723
|
+
}
|
|
5724
|
+
function inferPlatformFromOutDir(outDir) {
|
|
5725
|
+
const segment = outDir ? path.basename(path.normalize(outDir)) : void 0;
|
|
5726
|
+
if (!segment) return;
|
|
5727
|
+
const normalized = segment.trim().toLowerCase();
|
|
5728
|
+
if (normalized === "h5" || normalized === "web" || normalized === "app" || normalized === "app-plus" || normalized.startsWith("app-") || normalized.startsWith("mp-") || normalized.startsWith("quickapp-webview")) return normalized;
|
|
5729
|
+
}
|
|
5730
|
+
function isWebOrNativeAppPlatform(platform) {
|
|
5731
|
+
return platform === "h5" || platform === "web" || platform?.startsWith("web-") === true || platform === "app" || platform === "app-plus" || platform?.startsWith("app-") === true;
|
|
5732
|
+
}
|
|
5582
5733
|
/**
|
|
5583
5734
|
* @name WeappTailwindcss
|
|
5584
5735
|
* @description uni-app vite / uni-app-x 版本插件
|
|
@@ -5587,19 +5738,26 @@ const sourceCandidateScanSnapshotCache = new LRUCache({ max: SOURCE_CANDIDATE_SC
|
|
|
5587
5738
|
function WeappTailwindcss(options = {}) {
|
|
5588
5739
|
const hasExplicitAppType = typeof options.appType === "string" && options.appType.trim().length > 0;
|
|
5589
5740
|
const hasExplicitTailwindcssBasedir = typeof options.tailwindcssBasedir === "string" && options.tailwindcssBasedir.trim().length > 0;
|
|
5741
|
+
const rawCssEntries = Array.isArray(options.cssEntries) ? [...options.cssEntries] : void 0;
|
|
5590
5742
|
const opts = getCompilerContext({
|
|
5591
5743
|
...options,
|
|
5592
5744
|
__internalDeferMissingCssEntriesWarning: true
|
|
5593
5745
|
});
|
|
5594
|
-
const
|
|
5595
|
-
|
|
5596
|
-
|
|
5597
|
-
|
|
5746
|
+
const syncCssEntriesFromAnchor = (anchor) => {
|
|
5747
|
+
var _opts$tailwindcss;
|
|
5748
|
+
const normalizedCssEntries = normalizeCssEntries(rawCssEntries, anchor ?? process$1.cwd());
|
|
5749
|
+
if (!normalizedCssEntries) return false;
|
|
5750
|
+
const changed = !sameStringList(opts.cssEntries, normalizedCssEntries);
|
|
5751
|
+
opts.cssEntries = normalizedCssEntries;
|
|
5598
5752
|
opts.tailwindcss ?? (opts.tailwindcss = {});
|
|
5599
5753
|
(_opts$tailwindcss = opts.tailwindcss).v4 ?? (_opts$tailwindcss.v4 = {});
|
|
5600
|
-
|
|
5601
|
-
|
|
5602
|
-
|
|
5754
|
+
opts.tailwindcss.v4.cssEntries = normalizedCssEntries;
|
|
5755
|
+
if (opts.tailwindcssRuntimeOptions?.tailwindcss?.v4) opts.tailwindcssRuntimeOptions.tailwindcss.v4.cssEntries = normalizedCssEntries;
|
|
5756
|
+
if (opts.tailwindRuntime?.options?.tailwindcss?.v4) opts.tailwindRuntime.options.tailwindcss.v4.cssEntries = normalizedCssEntries;
|
|
5757
|
+
return changed;
|
|
5758
|
+
};
|
|
5759
|
+
syncCssEntriesFromAnchor(opts.tailwindcssBasedir);
|
|
5760
|
+
const { disabled, customAttributes, onLoad, mainCssChunkMatcher, styleHandler, jsHandler, tailwindRuntime, refreshTailwindcssRuntime, uniAppX, disabledDefaultTemplateHandler, styleInjector } = opts;
|
|
5603
5761
|
const initialTailwindRuntime = tailwindRuntime;
|
|
5604
5762
|
const refreshTailwindRuntime = refreshTailwindcssRuntime;
|
|
5605
5763
|
const uniAppXEnabled = isUniAppXEnabled(uniAppX);
|
|
@@ -5620,6 +5778,28 @@ function WeappTailwindcss(options = {}) {
|
|
|
5620
5778
|
tailwindcssMajorVersion,
|
|
5621
5779
|
uniAppX
|
|
5622
5780
|
});
|
|
5781
|
+
const resolveViteStylePlatform = () => {
|
|
5782
|
+
const explicit = normalizeViteStylePlatform(opts.cssOptions?.platform ?? opts.platform, opts.appType);
|
|
5783
|
+
if (explicit) return explicit;
|
|
5784
|
+
for (const key of ENV_PLATFORM_KEYS) {
|
|
5785
|
+
const envPlatform = normalizeViteStylePlatform(process$1.env[key], opts.appType);
|
|
5786
|
+
if (envPlatform) return envPlatform;
|
|
5787
|
+
}
|
|
5788
|
+
return inferPlatformFromOutDir(resolvedConfig?.build?.outDir);
|
|
5789
|
+
};
|
|
5790
|
+
const transformEarlyMiniProgramCss = (code) => {
|
|
5791
|
+
const platform = resolveViteStylePlatform();
|
|
5792
|
+
if (!shouldOwnTailwindGeneration || (platform ? isWebOrNativeAppPlatform(platform) : generatorBranch.isWeb)) return code;
|
|
5793
|
+
let transformedCode = code;
|
|
5794
|
+
if (transformedCode.includes("#if")) transformedCode = compileCssMacroConditionalComments(transformedCode, { platform: resolveViteStylePlatform() });
|
|
5795
|
+
if (transformedCode.includes("@layer")) transformedCode = unwrapUnsupportedCascadeLayers(transformedCode);
|
|
5796
|
+
return transformedCode;
|
|
5797
|
+
};
|
|
5798
|
+
const finalizeViteMiniProgramCss = (css) => {
|
|
5799
|
+
const platform = resolveViteStylePlatform();
|
|
5800
|
+
if (!shouldOwnTailwindGeneration || (platform ? isWebOrNativeAppPlatform(platform) : generatorBranch.isWeb)) return css;
|
|
5801
|
+
return unwrapUnsupportedCascadeLayers(css);
|
|
5802
|
+
};
|
|
5623
5803
|
const shouldInferAppType = !hasExplicitAppType && !generatorBranch.isWeb;
|
|
5624
5804
|
const hasInitialTailwindCssRoots = hasConfiguredTailwindV4CssRoots({
|
|
5625
5805
|
...options,
|
|
@@ -5756,6 +5936,15 @@ function WeappTailwindcss(options = {}) {
|
|
|
5756
5936
|
const getSourceCandidateSourcesForEntries = (entries, options) => sourceCandidateCollector.sourcesForEntries(entries, options);
|
|
5757
5937
|
const isWatchBuild = () => resolvedConfig?.command === "build" && resolvedConfig.build.watch != null;
|
|
5758
5938
|
const isWatchLikeBuild = () => isWatchBuild() || resolvedConfig?.command === "serve" || process$1.env["WEAPP_TW_WATCH_REGRESSION"] === "1" || process$1.env["WEAPP_TW_HMR_TIMING"] === "1";
|
|
5939
|
+
const isCurrentWebLikeStylePlatform = () => {
|
|
5940
|
+
const platform = resolveViteStylePlatform();
|
|
5941
|
+
return platform ? isWebOrNativeAppPlatform(platform) : generatorBranch.isWeb;
|
|
5942
|
+
};
|
|
5943
|
+
const isNuxtPageMacroHotModule = (id) => {
|
|
5944
|
+
if (typeof id !== "string" || !/[?&]macro=true(?:&|$)/.test(id)) return false;
|
|
5945
|
+
const cleanId = cleanUrl(id);
|
|
5946
|
+
return cleanId.includes("/pages/") && /\.(?:vue|tsx?|jsx?)$/.test(cleanId);
|
|
5947
|
+
};
|
|
5759
5948
|
const hasSourceCandidateScanState = () => sourceCandidateScanSignature !== void 0;
|
|
5760
5949
|
const normalizeSourceScanDependency = (file) => path.normalize(path.resolve(cleanUrl(file)));
|
|
5761
5950
|
const isSourceScanDependency = (file) => sourceScanDependencies.has(normalizeSourceScanDependency(file));
|
|
@@ -5955,7 +6144,8 @@ function WeappTailwindcss(options = {}) {
|
|
|
5955
6144
|
getExtraOptions: (file) => ({
|
|
5956
6145
|
...resolveViteCssHandlerExtraOptions(file),
|
|
5957
6146
|
...resolveUniAppXNativeCssHandlerOptions(opts)
|
|
5958
|
-
})
|
|
6147
|
+
}),
|
|
6148
|
+
getDynamicCssOptions: () => ({ cssPreflight: opts.cssPreflight })
|
|
5959
6149
|
});
|
|
5960
6150
|
const serveJsHandlerOptions = createJsHandlerOptionsFactory({
|
|
5961
6151
|
getMajorVersion: () => runtimeState.tailwindRuntime.majorVersion,
|
|
@@ -5999,10 +6189,11 @@ function WeappTailwindcss(options = {}) {
|
|
|
5999
6189
|
styleHandler,
|
|
6000
6190
|
debug,
|
|
6001
6191
|
previousCss: viteGeneratedCssByFile.get(file),
|
|
6002
|
-
deferEmptyScopedCssSource: shouldDeferEmptyScopedCssSource
|
|
6192
|
+
deferEmptyScopedCssSource: shouldDeferEmptyScopedCssSource,
|
|
6193
|
+
restoreLocalCssImports: !generatorBranch.isWeb
|
|
6003
6194
|
});
|
|
6004
6195
|
if (!generated) return;
|
|
6005
|
-
const tracedCss = annotateCssSourceTrace(generated.css, {
|
|
6196
|
+
const tracedCss = annotateCssSourceTrace(finalizeViteMiniProgramCss(generated.css), {
|
|
6006
6197
|
opts,
|
|
6007
6198
|
tokenSources: createCssTokenSourceMap(getSourceCandidateSourcesForEntries(void 0), opts)
|
|
6008
6199
|
});
|
|
@@ -6126,20 +6317,45 @@ function WeappTailwindcss(options = {}) {
|
|
|
6126
6317
|
{
|
|
6127
6318
|
name: `${vitePluginName}:source-candidates`,
|
|
6128
6319
|
enforce: "pre",
|
|
6129
|
-
async
|
|
6130
|
-
if (shouldOwnTailwindGeneration)
|
|
6131
|
-
|
|
6132
|
-
|
|
6133
|
-
|
|
6134
|
-
|
|
6135
|
-
|
|
6136
|
-
|
|
6137
|
-
|
|
6320
|
+
async load(id) {
|
|
6321
|
+
if (!shouldOwnTailwindGeneration || isWebOrNativeAppPlatform(resolveViteStylePlatform()) || !isCSSRequest(id) || !shouldCollectTransformedSourceCandidates(id)) return;
|
|
6322
|
+
const rawCode = await readFile(cleanUrl(id), "utf8").catch(() => void 0);
|
|
6323
|
+
if (typeof rawCode !== "string") return;
|
|
6324
|
+
const transformedCode = transformEarlyMiniProgramCss(rawCode);
|
|
6325
|
+
if (transformedCode === rawCode) return;
|
|
6326
|
+
cssMemory.rememberKnownSfcSource(id, transformedCode);
|
|
6327
|
+
return transformedCode;
|
|
6328
|
+
},
|
|
6329
|
+
transform: {
|
|
6330
|
+
order: "pre",
|
|
6331
|
+
async handler(code, id) {
|
|
6332
|
+
let transformedCode = code;
|
|
6333
|
+
if (shouldOwnTailwindGeneration && !generatorBranch.isWeb && isCSSRequest(id)) transformedCode = transformEarlyMiniProgramCss(code);
|
|
6334
|
+
const shouldReturnTransformedCode = transformedCode !== code;
|
|
6335
|
+
if (shouldOwnTailwindGeneration) cssMemory.rememberKnownSfcSource(id, transformedCode);
|
|
6336
|
+
if (!shouldOwnTailwindGeneration || !isSourceCandidateRequest(id) || !shouldCollectTransformedSourceCandidates(id)) {
|
|
6337
|
+
if (shouldReturnTransformedCode) return {
|
|
6338
|
+
code: transformedCode,
|
|
6339
|
+
map: null
|
|
6340
|
+
};
|
|
6138
6341
|
return;
|
|
6139
6342
|
}
|
|
6140
|
-
|
|
6141
|
-
|
|
6142
|
-
|
|
6343
|
+
return hmrTimingRecorder.measure("sourceCandidates.transform", async () => {
|
|
6344
|
+
invalidateRecordedGeneratorCandidates();
|
|
6345
|
+
const file = cleanUrl(id);
|
|
6346
|
+
if (sourceScanMatcher && !sourceScanMatcher(file)) {
|
|
6347
|
+
sourceCandidateCollector.remove(file);
|
|
6348
|
+
cacheCurrentSourceCandidateScan();
|
|
6349
|
+
return;
|
|
6350
|
+
}
|
|
6351
|
+
await sourceCandidateCollector.merge(id, transformedCode);
|
|
6352
|
+
cacheCurrentSourceCandidateScan();
|
|
6353
|
+
if (shouldReturnTransformedCode) return {
|
|
6354
|
+
code: transformedCode,
|
|
6355
|
+
map: null
|
|
6356
|
+
};
|
|
6357
|
+
}, { emit: false });
|
|
6358
|
+
}
|
|
6143
6359
|
},
|
|
6144
6360
|
async watchChange(id, change) {
|
|
6145
6361
|
await hmrTimingRecorder.measure("sourceCandidates.watchChange", async () => {
|
|
@@ -6157,13 +6373,27 @@ function WeappTailwindcss(options = {}) {
|
|
|
6157
6373
|
return hmrTimingRecorder.measure("sourceCandidates.handleHotUpdate", async () => {
|
|
6158
6374
|
const isSourceCandidateHotUpdate = shouldOwnTailwindGeneration && isSourceCandidateRequest(ctx.file);
|
|
6159
6375
|
await syncChangedSourceCandidateFile(ctx.file);
|
|
6160
|
-
|
|
6376
|
+
const isWebLikeHotUpdate = isCurrentWebLikeStylePlatform();
|
|
6377
|
+
if (isSourceCandidateHotUpdate) {
|
|
6378
|
+
invalidateRecordedGeneratorCandidates();
|
|
6379
|
+
if (isWebLikeHotUpdate) {
|
|
6380
|
+
await refreshRuntimeStateForAutoCssSources?.(true);
|
|
6381
|
+
await syncSourceCandidateScan({ force: true });
|
|
6382
|
+
}
|
|
6383
|
+
}
|
|
6161
6384
|
const cssModules = resolveHotTailwindCssModules(ctx, tailwindRootCssModuleIds);
|
|
6162
|
-
|
|
6385
|
+
const sourceModules = isSourceCandidateHotUpdate && !isSourceStyleRequest(ctx.file) ? resolveHotSourceModules(ctx) : ctx.modules;
|
|
6386
|
+
if (isSourceCandidateHotUpdate && !isSourceStyleRequest(ctx.file) && !isWebLikeHotUpdate && (!hasSelfAcceptingNonStyleHotModule(sourceModules) && cssModules.length === 0 || cssModules.length > 0 && isUniViteProject())) {
|
|
6387
|
+
sendFullReloadForUnresolvedHotUpdate(ctx);
|
|
6388
|
+
return [];
|
|
6389
|
+
}
|
|
6390
|
+
if (isWebLikeHotUpdate && isSourceCandidateHotUpdate && !isSourceStyleRequest(ctx.file) && ctx.modules.some((mod) => isNuxtPageMacroHotModule(mod.id ?? mod.url))) {
|
|
6163
6391
|
sendFullReloadForUnresolvedHotUpdate(ctx);
|
|
6164
6392
|
return [];
|
|
6165
6393
|
}
|
|
6166
6394
|
sendSupplementalCssHotUpdates(ctx, cssModules);
|
|
6395
|
+
if (isWebLikeHotUpdate && isSourceCandidateHotUpdate && !isSourceStyleRequest(ctx.file)) return;
|
|
6396
|
+
if (isSourceCandidateHotUpdate && !isSourceStyleRequest(ctx.file) && cssModules.length > 0) return [...sourceModules, ...cssModules];
|
|
6167
6397
|
return cssModules.length > 0 ? [...ctx.modules, ...cssModules] : void 0;
|
|
6168
6398
|
}, { emit: false });
|
|
6169
6399
|
},
|
|
@@ -6227,6 +6457,7 @@ function WeappTailwindcss(options = {}) {
|
|
|
6227
6457
|
if (opts.tailwindcssBasedir !== nextTailwindcssBasedir) {
|
|
6228
6458
|
const previousBasedir = opts.tailwindcssBasedir;
|
|
6229
6459
|
opts.tailwindcssBasedir = nextTailwindcssBasedir;
|
|
6460
|
+
shouldRefreshRuntime = syncCssEntriesFromAnchor(nextTailwindcssBasedir) || shouldRefreshRuntime;
|
|
6230
6461
|
debug("align tailwindcss basedir with vite root: %s -> %s", previousBasedir ?? "undefined", nextTailwindcssBasedir);
|
|
6231
6462
|
shouldRefreshRuntime = true;
|
|
6232
6463
|
}
|
|
@@ -6259,6 +6490,7 @@ function WeappTailwindcss(options = {}) {
|
|
|
6259
6490
|
];
|
|
6260
6491
|
if (uniAppXPlugins) plugins.push(...uniAppXPlugins);
|
|
6261
6492
|
plugins.push(cssFinalizerOutputPlugin);
|
|
6493
|
+
plugins.push(...createBuiltinViteStyleInjectorPlugins(styleInjector, () => opts.appType));
|
|
6262
6494
|
return plugins;
|
|
6263
6495
|
}
|
|
6264
6496
|
//#endregion
|