weapp-tailwindcss 5.1.3 → 5.1.4
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/local-imports.d.ts +1 -10
- package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/temporary-css-assets.d.ts +1 -1
- package/dist/bundlers/vite/processed-css-assets.d.ts +1 -0
- package/dist/{context-B07Vf584.mjs → context-Bkpmt3ja.mjs} +31 -5
- package/dist/{context-D75pwtBW.js → context-DCVMkTRj.js} +36 -4
- 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.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-aQMZ0M7c.mjs → gulp-0RsqkF_d.mjs} +4 -4
- package/dist/{gulp-B_u8NjQL.js → gulp-Bogfnoki.js} +7 -6
- package/dist/gulp.js +1 -1
- package/dist/gulp.mjs +1 -1
- package/dist/{hmr-timing-DLYQTCDb.mjs → hmr-timing-BRNaz8Od.mjs} +41 -148
- package/dist/{hmr-timing-DOoHun3i.js → hmr-timing-BV6nFPoT.js} +41 -166
- package/dist/index.js +4 -4
- package/dist/index.mjs +4 -4
- package/dist/postcss.js +2 -2
- package/dist/postcss.mjs +2 -2
- package/dist/presets.js +2 -2
- package/dist/presets.mjs +2 -2
- package/dist/rspack.js +1 -1
- package/dist/rspack.mjs +1 -1
- package/dist/{source-candidate-scan-signature-pS87mdHZ.mjs → source-candidate-scan-signature-BB1hvW68.mjs} +12 -6
- package/dist/{source-candidate-scan-signature-DzwebZrf.js → source-candidate-scan-signature-CaDT0gkj.js} +13 -6
- package/dist/tailwindcss/v4-engine/css-macro-source.d.ts +2 -0
- package/dist/{tailwindcss-BwV3_Ryc.mjs → tailwindcss-D0JF0fuZ.mjs} +4 -4
- package/dist/{tailwindcss-BSCvrs1p.js → tailwindcss-D2xs4OEu.js} +4 -4
- package/dist/{transform-Clj7R818.mjs → transform-BP86eSZp.mjs} +1 -1
- package/dist/{transform-fin-OTVD.js → transform-CXCQ28Tc.js} +1 -1
- 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-5Wn0PIzJ.mjs → vite-B1SlBmqO.mjs} +212 -44
- package/dist/{vite-CkVMSDDp.js → vite-BYgT1ir9.js} +214 -46
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.js +89 -191
- package/dist/{webpack-DEag6ueE.mjs → webpack-Bg6pefpb.mjs} +49 -6
- package/dist/{webpack-hvSFaicc.js → webpack-khSwkXP5.js} +50 -7
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +3 -3
- 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-Bkpmt3ja.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-D0JF0fuZ.mjs";
|
|
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-BRNaz8Od.mjs";
|
|
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-BB1hvW68.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-BP86eSZp.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];
|
|
@@ -2127,6 +2136,7 @@ function shouldInjectViteProcessedCssResult(opts, targetFile, sourceFile, option
|
|
|
2127
2136
|
if (options.injectIntoMain === true) return isRootStyleOutputFile(targetFile) || typeof options.outputFile === "string" && normalizeOutputPathKey(options.outputFile) === normalizeOutputPathKey(targetFile);
|
|
2128
2137
|
if (options.injectIntoMain === false) return false;
|
|
2129
2138
|
const targetFileKey = normalizeOutputPathKey(targetFile);
|
|
2139
|
+
if (typeof options.outputFile === "string" && normalizeOutputPathKey(options.outputFile) === targetFileKey) return true;
|
|
2130
2140
|
return normalizeOutputPathKey(sourceFile) !== targetFileKey && (opts.mainCssChunkMatcher(sourceFile, opts.appType) || typeof options.outputFile === "string" && normalizeOutputPathKey(options.outputFile) !== targetFileKey && opts.mainCssChunkMatcher(options.outputFile, opts.appType));
|
|
2131
2141
|
}
|
|
2132
2142
|
function shouldReplayViteProcessedCssIntoMainCss(opts, file, sourceFile, outputFile, subpackageRoots) {
|
|
@@ -2162,7 +2172,7 @@ function resolvePreservedImportShellInjectionTarget(opts, bundle, file, css) {
|
|
|
2162
2172
|
}
|
|
2163
2173
|
function shouldUseCssAssetAsMainInjectionTarget(opts, file, records) {
|
|
2164
2174
|
const fileKey = normalizeOutputPathKey(file);
|
|
2165
|
-
if (!isRootStyleOutputFile(file) && records.some((record) => typeof record.outputFile === "string" && normalizeOutputPathKey(record.outputFile) === fileKey)) return
|
|
2175
|
+
if (!isRootStyleOutputFile(file) && records.some((record) => typeof record.outputFile === "string" && normalizeOutputPathKey(record.outputFile) === fileKey)) return true;
|
|
2166
2176
|
if (!isRootStyleOutputFile(file)) return records.some((record) => record.injectIntoMain === true && typeof record.outputFile === "string" && normalizeOutputPathKey(record.outputFile) === fileKey);
|
|
2167
2177
|
if (records.some((record) => {
|
|
2168
2178
|
if (record.injectIntoMain !== true) return false;
|
|
@@ -2210,6 +2220,12 @@ function collectBundleAssetFiles(bundle) {
|
|
|
2210
2220
|
}
|
|
2211
2221
|
return files;
|
|
2212
2222
|
}
|
|
2223
|
+
function findBundleAssetByOutputFile(bundle, file) {
|
|
2224
|
+
const fileKey = normalizeOutputPathKey(file);
|
|
2225
|
+
return Object.entries(bundle).find(([bundleFile, output]) => {
|
|
2226
|
+
return output.type === "asset" && normalizeOutputPathKey(getAssetFile$1(bundleFile, output)) === fileKey;
|
|
2227
|
+
})?.[1];
|
|
2228
|
+
}
|
|
2213
2229
|
function isCssImportOnlyBundleAsset(bundle, file, css) {
|
|
2214
2230
|
const importedStyleFiles = collectImportedStyleFiles(css, file);
|
|
2215
2231
|
if (importedStyleFiles.size === 0) return false;
|
|
@@ -2229,6 +2245,13 @@ function isCoveredViteGeneratedSourceAsset(file, existingAssetFiles, resolveVite
|
|
|
2229
2245
|
const resolvedOutputFile = normalizeOutputPathKey(resolveViteProcessedCssOutputFile?.(file) ?? file);
|
|
2230
2246
|
return resolvedOutputFile !== normalizeOutputPathKey(file) && existingAssetFiles.has(resolvedOutputFile);
|
|
2231
2247
|
}
|
|
2248
|
+
function resolveViteGeneratedCssMarkerOutputFile(file, markerFile, existingAssetFiles, resolveViteProcessedCssOutputFile) {
|
|
2249
|
+
const resolvedFromFile = normalizeOutputPathKey(resolveViteProcessedCssOutputFile?.(file) ?? file);
|
|
2250
|
+
if (!markerFile) return resolvedFromFile;
|
|
2251
|
+
const resolvedFromMarker = normalizeOutputPathKey(resolveViteProcessedCssOutputFile?.(markerFile) ?? markerFile);
|
|
2252
|
+
if (resolvedFromMarker !== resolvedFromFile && existingAssetFiles.has(resolvedFromMarker)) return resolvedFromMarker;
|
|
2253
|
+
return resolvedFromFile;
|
|
2254
|
+
}
|
|
2232
2255
|
function isSourceRootPrefixedOutputFile(file, outputFile) {
|
|
2233
2256
|
const fileKey = normalizeOutputPathKey(file);
|
|
2234
2257
|
const outputFileKey = normalizeOutputPathKey(outputFile);
|
|
@@ -2245,10 +2268,30 @@ function collectViteProcessedCssAssetResults(bundle, options) {
|
|
|
2245
2268
|
let nextCss = resolveViteProcessedCssAssetSource(file, rawSource, options.resolveViteProcessedCssOutputFile);
|
|
2246
2269
|
const singleMarkerFile = collectSingleViteGeneratedCssMarkerFile(rawSource);
|
|
2247
2270
|
if (singleMarkerFile && (options.subpackageRoots == null || !isSubpackageOutputFile(file, options.subpackageRoots)) && shouldFilterRootGeneratedCssMarkerForScopedAsset(file, singleMarkerFile, options.resolveViteProcessedCssOutputFile)) nextCss = removeCssCoveredByRootStyleBundleSources(bundle, file, nextCss);
|
|
2271
|
+
nextCss = options.transformCss?.(nextCss, file) ?? nextCss;
|
|
2248
2272
|
if (nextCss !== rawSource) output.source = nextCss;
|
|
2249
2273
|
options.markCssAssetProcessed?.(output, file);
|
|
2250
2274
|
options.recordCssAssetResult?.(file, nextCss);
|
|
2251
|
-
const resolvedOutputFile = options.resolveViteProcessedCssOutputFile
|
|
2275
|
+
const resolvedOutputFile = resolveViteGeneratedCssMarkerOutputFile(file, singleMarkerFile, existingAssetFiles, options.resolveViteProcessedCssOutputFile);
|
|
2276
|
+
if (singleMarkerFile && normalizeOutputPathKey(resolvedOutputFile) !== normalizeOutputPathKey(file) && !isRootStyleOutputFile(resolvedOutputFile) && existingAssetFiles.has(normalizeOutputPathKey(resolvedOutputFile))) {
|
|
2277
|
+
const targetAsset = findBundleAssetByOutputFile(bundle, resolvedOutputFile);
|
|
2278
|
+
if (targetAsset) {
|
|
2279
|
+
const targetRawSource = readAssetSource$2(targetAsset);
|
|
2280
|
+
const targetNextCss = appendCss$1(targetRawSource, filterExistingCssRules(targetRawSource, nextCss).trim());
|
|
2281
|
+
if (targetNextCss !== targetRawSource) {
|
|
2282
|
+
targetAsset.source = targetNextCss;
|
|
2283
|
+
options.markCssAssetProcessed?.(targetAsset, resolvedOutputFile);
|
|
2284
|
+
options.recordCssAssetResult?.(resolvedOutputFile, targetNextCss);
|
|
2285
|
+
}
|
|
2286
|
+
clearAssetSource(output);
|
|
2287
|
+
options.recordCssAssetResult?.(file, "");
|
|
2288
|
+
options.recordViteProcessedCssAssetResult?.(resolvedOutputFile, targetNextCss, { outputFile: resolvedOutputFile });
|
|
2289
|
+
if (isCoveredViteGeneratedSourceAsset(file, existingAssetFiles, options.resolveViteProcessedCssOutputFile)) delete bundle[bundleFile];
|
|
2290
|
+
options.debug?.("move vite-generated css asset by marker source: %s -> %s bytes=%d", file, resolvedOutputFile, nextCss.length);
|
|
2291
|
+
collected++;
|
|
2292
|
+
continue;
|
|
2293
|
+
}
|
|
2294
|
+
}
|
|
2252
2295
|
const shouldReplayIntoMainCss = options.opts != null && shouldReplayViteProcessedCssIntoMainCss(options.opts, file, singleMarkerFile, resolvedOutputFile, options.subpackageRoots);
|
|
2253
2296
|
options.recordViteProcessedCssAssetResult?.(file, nextCss, {
|
|
2254
2297
|
injectIntoMain: shouldReplayIntoMainCss || void 0,
|
|
@@ -3545,6 +3588,14 @@ function resolveCurrentSourceCandidateSource(options) {
|
|
|
3545
3588
|
}
|
|
3546
3589
|
//#endregion
|
|
3547
3590
|
//#region src/bundlers/vite/generate-bundle/tailwind-v4-css-source.ts
|
|
3591
|
+
function createStableTextSignature(input) {
|
|
3592
|
+
let hash = 2166136261;
|
|
3593
|
+
for (let i = 0; i < input.length; i++) {
|
|
3594
|
+
hash ^= input.charCodeAt(i);
|
|
3595
|
+
hash = Math.imul(hash, 16777619);
|
|
3596
|
+
}
|
|
3597
|
+
return (hash >>> 0).toString(36);
|
|
3598
|
+
}
|
|
3548
3599
|
function collectTailwindV4SourceFingerprint(source) {
|
|
3549
3600
|
const tokens = /* @__PURE__ */ new Set();
|
|
3550
3601
|
const add = (prefix, value) => {
|
|
@@ -3556,6 +3607,22 @@ function collectTailwindV4SourceFingerprint(source) {
|
|
|
3556
3607
|
add("config-request", configRequest.replace(/\\/g, "/"));
|
|
3557
3608
|
}
|
|
3558
3609
|
for (const match of source.matchAll(/@source\s+(not\s+)?(["'])(.+?)\2\s*;?/g)) add(match[1] ? "source:not" : "source", match[3]);
|
|
3610
|
+
for (const match of source.matchAll(/@plugin\s+(["'])(.+?)\1\s*(?:\{([\s\S]*?)\}|;)/g)) {
|
|
3611
|
+
const request = match[2];
|
|
3612
|
+
const optionBlock = match[3];
|
|
3613
|
+
add("plugin", request);
|
|
3614
|
+
add("plugin-request", request.replace(/\\/g, "/"));
|
|
3615
|
+
if (optionBlock !== void 0) add("plugin-options", `${request}:${createStableTextSignature(optionBlock)}`);
|
|
3616
|
+
}
|
|
3617
|
+
try {
|
|
3618
|
+
postcss.parse(source).walkAtRules("plugin", (rule) => {
|
|
3619
|
+
const request = /^(['"])(.+?)\1/.exec(rule.params.trim())?.[2];
|
|
3620
|
+
if (!request || !rule.nodes?.length) return;
|
|
3621
|
+
rule.walkDecls((decl) => {
|
|
3622
|
+
add("plugin-option", `${request}:${decl.prop}:${decl.value}`);
|
|
3623
|
+
});
|
|
3624
|
+
});
|
|
3625
|
+
} catch {}
|
|
3559
3626
|
for (const match of source.matchAll(/@custom-variant\s+([^{\s]+)/g)) add("custom-variant", match[1]);
|
|
3560
3627
|
for (const match of source.matchAll(/@(?:theme|utility|variant|layer)\s+([^{;\s]+)/g)) add("directive", match[1]);
|
|
3561
3628
|
for (const match of source.matchAll(/--[\w-]+(?=\s*:)/g)) add("theme-token", match[0]);
|
|
@@ -3617,7 +3684,7 @@ function createTemporaryCssAssetSourceResolver(entries) {
|
|
|
3617
3684
|
const queuedEntries = entries.filter((entry) => {
|
|
3618
3685
|
const entryFile = normalizeCssSourceKey(entry.file);
|
|
3619
3686
|
const outputFile = normalizeCssSourceKey(entry.outputFile);
|
|
3620
|
-
if (
|
|
3687
|
+
if (outputFile === entryFile || !outputFile.includes("/") || seenEntryFiles.has(entryFile)) return false;
|
|
3621
3688
|
seenEntryFiles.add(entryFile);
|
|
3622
3689
|
return true;
|
|
3623
3690
|
});
|
|
@@ -3628,9 +3695,16 @@ function createTemporaryCssAssetSourceResolver(entries) {
|
|
|
3628
3695
|
if (!sourceFile) return;
|
|
3629
3696
|
usedEntryFiles.add(normalizeCssSourceKey(sourceFile));
|
|
3630
3697
|
},
|
|
3631
|
-
resolve(outputFile) {
|
|
3698
|
+
resolve(outputFile, rawSource) {
|
|
3632
3699
|
if (!isTemporaryCssAssetFile(outputFile)) return;
|
|
3633
|
-
const
|
|
3700
|
+
const availableEntries = queuedEntries.filter((item) => !usedEntryFiles.has(normalizeCssSourceKey(item.file)));
|
|
3701
|
+
const scoredEntries = rawSource ? availableEntries.map((entry) => ({
|
|
3702
|
+
entry,
|
|
3703
|
+
score: scoreConfiguredTailwindV4SourceForRawSource(rawSource, entry.source)
|
|
3704
|
+
})).filter((item) => item.score > 0).sort((a, b) => b.score - a.score) : [];
|
|
3705
|
+
const bestScore = scoredEntries[0]?.score;
|
|
3706
|
+
const bestEntries = bestScore ? scoredEntries.filter((item) => item.score === bestScore) : [];
|
|
3707
|
+
const entry = bestEntries.length === 1 ? bestEntries[0]?.entry : availableEntries.find((item) => hasTailwindGenerationSource(item.source));
|
|
3634
3708
|
if (!entry) return;
|
|
3635
3709
|
usedEntryFiles.add(normalizeCssSourceKey(entry.file));
|
|
3636
3710
|
return {
|
|
@@ -4046,7 +4120,7 @@ function createGenerateBundleHook(context) {
|
|
|
4046
4120
|
...[...runtimeLinkedCssFiles].filter((file) => !snapshot.sourceHashByFile.has(file)).map((file) => {
|
|
4047
4121
|
const outputFile = resolveViteCssPipelineOutputFile(file, opts, rootDir, isWebGeneratorTarget, shouldPreserveAppCssExtension, sourceRoot, defaultStyleOutputExtension, bundleFiles);
|
|
4048
4122
|
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
|
|
4123
|
+
return inferredSourceStyle && currentSubpackageRoots ? {
|
|
4050
4124
|
file: inferredSourceStyle.sourceFile,
|
|
4051
4125
|
outputFile,
|
|
4052
4126
|
source: inferredSourceStyle.rawSource
|
|
@@ -4057,6 +4131,14 @@ function createGenerateBundleHook(context) {
|
|
|
4057
4131
|
outputFile: remembered.outputFile,
|
|
4058
4132
|
source: remembered.rawSource
|
|
4059
4133
|
})),
|
|
4134
|
+
...getConfiguredTailwindV4CssSourceEntries().map((entry) => {
|
|
4135
|
+
const outputFile = resolveMatchedCssSourceOutputFile(entry.file);
|
|
4136
|
+
return outputFile ? {
|
|
4137
|
+
file: entry.file,
|
|
4138
|
+
outputFile,
|
|
4139
|
+
source: entry.source
|
|
4140
|
+
} : void 0;
|
|
4141
|
+
}).filter((entry) => entry != null),
|
|
4060
4142
|
...configuredTailwindV4CssSourceEntriesForScope.map((entry) => {
|
|
4061
4143
|
const outputFile = resolveMatchedCssSourceOutputFile(entry.file);
|
|
4062
4144
|
return outputFile && currentSubpackageRoots && isSubpackageOutputFile(outputFile, currentSubpackageRoots) ? {
|
|
@@ -4218,7 +4300,7 @@ function createGenerateBundleHook(context) {
|
|
|
4218
4300
|
hasUsableRememberedTailwindSource = false;
|
|
4219
4301
|
}
|
|
4220
4302
|
if (isTemporaryCssAssetFile(outputFile) && hasTailwindGenerationSource(rawSource)) {
|
|
4221
|
-
const resolvedTemporarySource = temporaryCssAssetSourceResolver.resolve(outputFile);
|
|
4303
|
+
const resolvedTemporarySource = temporaryCssAssetSourceResolver.resolve(outputFile, rawSource);
|
|
4222
4304
|
if (resolvedTemporarySource) {
|
|
4223
4305
|
outputFile = resolveMatchedOutputFileForCurrentAsset(resolvedTemporarySource.sourceFile) ?? resolvedTemporarySource.outputFile;
|
|
4224
4306
|
activeViteCssCacheFiles.add(normalizeViteCssCacheKey(outputFile));
|
|
@@ -4250,7 +4332,7 @@ function createGenerateBundleHook(context) {
|
|
|
4250
4332
|
outputFile
|
|
4251
4333
|
}];
|
|
4252
4334
|
} else if (isTemporaryCssAssetFile(outputFile) && configuredTailwindV4CssSourceEntries.length > 1) {
|
|
4253
|
-
const resolvedTemporarySource = temporaryCssAssetSourceResolver.resolve(outputFile);
|
|
4335
|
+
const resolvedTemporarySource = temporaryCssAssetSourceResolver.resolve(outputFile, rawSource);
|
|
4254
4336
|
if (resolvedTemporarySource) {
|
|
4255
4337
|
outputFile = resolveMatchedOutputFileForCurrentAsset(resolvedTemporarySource.sourceFile) ?? resolvedTemporarySource.outputFile;
|
|
4256
4338
|
activeViteCssCacheFiles.add(normalizeViteCssCacheKey(outputFile));
|
|
@@ -4636,6 +4718,7 @@ function registerGeneratorDependencies(ctx, dependencies) {
|
|
|
4636
4718
|
function createCssHandlerOptions(opts, majorVersion, file) {
|
|
4637
4719
|
return {
|
|
4638
4720
|
...resolveUniAppXNativeCssHandlerOptions(opts),
|
|
4721
|
+
cssPreflight: opts.cssPreflight,
|
|
4639
4722
|
isMainChunk: opts.mainCssChunkMatcher(file, opts.appType),
|
|
4640
4723
|
postcssOptions: { options: { from: file } },
|
|
4641
4724
|
...normalizeStyleHandlerMajorVersion(majorVersion) === void 0 ? {} : { majorVersion: 4 }
|
|
@@ -4659,6 +4742,9 @@ function shouldFinalizeProcessedCssAsset(opts, file) {
|
|
|
4659
4742
|
function collectViteProcessedCssSources(getViteProcessedCssAssetResults) {
|
|
4660
4743
|
return [...getViteProcessedCssAssetResults?.() ?? []].map(([, record]) => typeof record === "string" ? record : record.css);
|
|
4661
4744
|
}
|
|
4745
|
+
function finalizeWebCss(css, enabled, webCompat) {
|
|
4746
|
+
return enabled ? transformWebCssCompat(css, webCompat) : css;
|
|
4747
|
+
}
|
|
4662
4748
|
function createViteCssFinalizerOutputPlugin(context) {
|
|
4663
4749
|
return {
|
|
4664
4750
|
name: "weapp-tailwindcss:adaptor:css-finalizer",
|
|
@@ -4669,13 +4755,14 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
4669
4755
|
const { opts, runtimeState, ensureRuntimeClassSet, isCssAssetProcessed, markCssAssetProcessed, debug, getResolvedConfig, recordCssAssetResult, recordViteProcessedCssAssetResult, getViteProcessedCssAssetResults, getRecordedGeneratorCandidates, getSourceCandidates, getSourceCandidatesForEntries, getSourceCandidateSourcesForEntries, waitForSourceCandidateSyncs, rememberMainCssSource, getRememberedMainCssSource, isViteProcessedCssAsset } = context;
|
|
4670
4756
|
const resolvedConfig = getResolvedConfig();
|
|
4671
4757
|
const uniUtsPlatform = resolveUniUtsPlatform();
|
|
4672
|
-
const
|
|
4758
|
+
const generatorOptions = normalizeWeappTailwindcssGeneratorOptions(opts.generator, {
|
|
4673
4759
|
appType: opts.appType,
|
|
4674
4760
|
platform: opts.cssOptions?.platform ?? opts.platform,
|
|
4675
4761
|
tailwindcssMajorVersion: runtimeState.tailwindRuntime.majorVersion,
|
|
4676
4762
|
uniAppX: opts.uniAppX,
|
|
4677
4763
|
uniUtsPlatform
|
|
4678
|
-
})
|
|
4764
|
+
});
|
|
4765
|
+
const generatorBranch = resolveGeneratorRuntimeBranch(generatorOptions, {
|
|
4679
4766
|
appType: opts.appType,
|
|
4680
4767
|
platform: opts.cssOptions?.platform ?? opts.platform,
|
|
4681
4768
|
tailwindcssMajorVersion: runtimeState.tailwindRuntime.majorVersion,
|
|
@@ -4702,6 +4789,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
4702
4789
|
recordCssAssetResult,
|
|
4703
4790
|
recordViteProcessedCssAssetResult,
|
|
4704
4791
|
resolveViteProcessedCssOutputFile: (file) => resolveViteCssPipelineOutputFile(file, opts, rootDir, isWebGeneratorTarget, isNativeAppStyleTarget, sourceRoot, resolveMiniProgramStyleOutputExtension({ files: Object.keys(bundle) }), Object.keys(bundle)),
|
|
4792
|
+
transformCss: (css) => finalizeWebCss(css, generatorBranch.isWeb, generatorOptions.webCompat),
|
|
4705
4793
|
debug
|
|
4706
4794
|
});
|
|
4707
4795
|
};
|
|
@@ -4774,7 +4862,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
4774
4862
|
const file = output.fileName || bundleFile;
|
|
4775
4863
|
const rawSource = output.source.toString();
|
|
4776
4864
|
if (isViteProcessedCssAsset?.(output, file)) {
|
|
4777
|
-
const nextCss = annotateCss(stripBundlerGeneratedCssMarkers(rawSource));
|
|
4865
|
+
const nextCss = annotateCss(finalizeWebCss(stripBundlerGeneratedCssMarkers(rawSource), generatorBranch.isWeb, generatorOptions.webCompat));
|
|
4778
4866
|
output.source = nextCss;
|
|
4779
4867
|
markCssAssetProcessed(output, file);
|
|
4780
4868
|
recordCssAssetResult?.(file, nextCss);
|
|
@@ -4808,7 +4896,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
4808
4896
|
styleHandler: opts.styleHandler,
|
|
4809
4897
|
debug
|
|
4810
4898
|
}) : void 0;
|
|
4811
|
-
const nextCss = annotateCss(generated?.css ?? (generatorBranch.isWeb ? rawSource : (await opts.styleHandler(rawSource, cssHandlerOptions)).css));
|
|
4899
|
+
const nextCss = annotateCss(generated?.css ?? (generatorBranch.isWeb ? finalizeWebCss(rawSource, true, generatorOptions.webCompat) : (await opts.styleHandler(rawSource, cssHandlerOptions)).css));
|
|
4812
4900
|
if (generated) {
|
|
4813
4901
|
registerGeneratorDependencies(this, generated.dependencies);
|
|
4814
4902
|
debug("css finalizer generated result: %s bytes=%d", file, nextCss.length);
|
|
@@ -5579,6 +5667,30 @@ const weappTailwindcssPackageDir = resolvePackageDir("weapp-tailwindcss");
|
|
|
5579
5667
|
const weappTailwindcssDirPosix = slash(weappTailwindcssPackageDir);
|
|
5580
5668
|
const SOURCE_CANDIDATE_SCAN_CACHE_MAX = 8;
|
|
5581
5669
|
const sourceCandidateScanSnapshotCache = new LRUCache({ max: SOURCE_CANDIDATE_SCAN_CACHE_MAX });
|
|
5670
|
+
const ENV_PLATFORM_KEYS = [
|
|
5671
|
+
"UNI_PLATFORM",
|
|
5672
|
+
"UNI_UTS_PLATFORM",
|
|
5673
|
+
"TARO_ENV",
|
|
5674
|
+
"MPX_CURRENT_TARGET_MODE",
|
|
5675
|
+
"MPX_CLI_MODE"
|
|
5676
|
+
];
|
|
5677
|
+
function sameStringList(first, second) {
|
|
5678
|
+
if (first === second) return true;
|
|
5679
|
+
if (!first || !second || first.length !== second.length) return false;
|
|
5680
|
+
return first.every((item, index) => item === second[index]);
|
|
5681
|
+
}
|
|
5682
|
+
function normalizeViteStylePlatform(value, appType) {
|
|
5683
|
+
return normalizeFrameworkStylePlatform(value, appType);
|
|
5684
|
+
}
|
|
5685
|
+
function inferPlatformFromOutDir(outDir) {
|
|
5686
|
+
const segment = outDir ? path.basename(path.normalize(outDir)) : void 0;
|
|
5687
|
+
if (!segment) return;
|
|
5688
|
+
const normalized = segment.trim().toLowerCase();
|
|
5689
|
+
if (normalized === "h5" || normalized === "web" || normalized === "app" || normalized === "app-plus" || normalized.startsWith("app-") || normalized.startsWith("mp-") || normalized.startsWith("quickapp-webview")) return normalized;
|
|
5690
|
+
}
|
|
5691
|
+
function isWebOrNativeAppPlatform(platform) {
|
|
5692
|
+
return platform === "h5" || platform === "web" || platform?.startsWith("web-") === true || platform === "app" || platform === "app-plus" || platform?.startsWith("app-") === true;
|
|
5693
|
+
}
|
|
5582
5694
|
/**
|
|
5583
5695
|
* @name WeappTailwindcss
|
|
5584
5696
|
* @description uni-app vite / uni-app-x 版本插件
|
|
@@ -5587,18 +5699,25 @@ const sourceCandidateScanSnapshotCache = new LRUCache({ max: SOURCE_CANDIDATE_SC
|
|
|
5587
5699
|
function WeappTailwindcss(options = {}) {
|
|
5588
5700
|
const hasExplicitAppType = typeof options.appType === "string" && options.appType.trim().length > 0;
|
|
5589
5701
|
const hasExplicitTailwindcssBasedir = typeof options.tailwindcssBasedir === "string" && options.tailwindcssBasedir.trim().length > 0;
|
|
5702
|
+
const rawCssEntries = Array.isArray(options.cssEntries) ? [...options.cssEntries] : void 0;
|
|
5590
5703
|
const opts = getCompilerContext({
|
|
5591
5704
|
...options,
|
|
5592
5705
|
__internalDeferMissingCssEntriesWarning: true
|
|
5593
5706
|
});
|
|
5594
|
-
const
|
|
5595
|
-
|
|
5596
|
-
|
|
5597
|
-
|
|
5707
|
+
const syncCssEntriesFromAnchor = (anchor) => {
|
|
5708
|
+
var _opts$tailwindcss;
|
|
5709
|
+
const normalizedCssEntries = normalizeCssEntries(rawCssEntries, anchor ?? process$1.cwd());
|
|
5710
|
+
if (!normalizedCssEntries) return false;
|
|
5711
|
+
const changed = !sameStringList(opts.cssEntries, normalizedCssEntries);
|
|
5712
|
+
opts.cssEntries = normalizedCssEntries;
|
|
5598
5713
|
opts.tailwindcss ?? (opts.tailwindcss = {});
|
|
5599
5714
|
(_opts$tailwindcss = opts.tailwindcss).v4 ?? (_opts$tailwindcss.v4 = {});
|
|
5600
|
-
|
|
5601
|
-
|
|
5715
|
+
opts.tailwindcss.v4.cssEntries = normalizedCssEntries;
|
|
5716
|
+
if (opts.tailwindcssRuntimeOptions?.tailwindcss?.v4) opts.tailwindcssRuntimeOptions.tailwindcss.v4.cssEntries = normalizedCssEntries;
|
|
5717
|
+
if (opts.tailwindRuntime?.options?.tailwindcss?.v4) opts.tailwindRuntime.options.tailwindcss.v4.cssEntries = normalizedCssEntries;
|
|
5718
|
+
return changed;
|
|
5719
|
+
};
|
|
5720
|
+
syncCssEntriesFromAnchor(opts.tailwindcssBasedir);
|
|
5602
5721
|
const { disabled, customAttributes, onLoad, mainCssChunkMatcher, styleHandler, jsHandler, tailwindRuntime, refreshTailwindcssRuntime, uniAppX, disabledDefaultTemplateHandler } = opts;
|
|
5603
5722
|
const initialTailwindRuntime = tailwindRuntime;
|
|
5604
5723
|
const refreshTailwindRuntime = refreshTailwindcssRuntime;
|
|
@@ -5620,6 +5739,28 @@ function WeappTailwindcss(options = {}) {
|
|
|
5620
5739
|
tailwindcssMajorVersion,
|
|
5621
5740
|
uniAppX
|
|
5622
5741
|
});
|
|
5742
|
+
const resolveViteStylePlatform = () => {
|
|
5743
|
+
const explicit = normalizeViteStylePlatform(opts.cssOptions?.platform ?? opts.platform, opts.appType);
|
|
5744
|
+
if (explicit) return explicit;
|
|
5745
|
+
for (const key of ENV_PLATFORM_KEYS) {
|
|
5746
|
+
const envPlatform = normalizeViteStylePlatform(process$1.env[key], opts.appType);
|
|
5747
|
+
if (envPlatform) return envPlatform;
|
|
5748
|
+
}
|
|
5749
|
+
return inferPlatformFromOutDir(resolvedConfig?.build?.outDir);
|
|
5750
|
+
};
|
|
5751
|
+
const transformEarlyMiniProgramCss = (code) => {
|
|
5752
|
+
const platform = resolveViteStylePlatform();
|
|
5753
|
+
if (!shouldOwnTailwindGeneration || (platform ? isWebOrNativeAppPlatform(platform) : generatorBranch.isWeb)) return code;
|
|
5754
|
+
let transformedCode = code;
|
|
5755
|
+
if (transformedCode.includes("#if")) transformedCode = compileCssMacroConditionalComments(transformedCode, { platform: resolveViteStylePlatform() });
|
|
5756
|
+
if (transformedCode.includes("@layer")) transformedCode = unwrapUnsupportedCascadeLayers(transformedCode);
|
|
5757
|
+
return transformedCode;
|
|
5758
|
+
};
|
|
5759
|
+
const finalizeViteMiniProgramCss = (css) => {
|
|
5760
|
+
const platform = resolveViteStylePlatform();
|
|
5761
|
+
if (!shouldOwnTailwindGeneration || (platform ? isWebOrNativeAppPlatform(platform) : generatorBranch.isWeb)) return css;
|
|
5762
|
+
return unwrapUnsupportedCascadeLayers(css);
|
|
5763
|
+
};
|
|
5623
5764
|
const shouldInferAppType = !hasExplicitAppType && !generatorBranch.isWeb;
|
|
5624
5765
|
const hasInitialTailwindCssRoots = hasConfiguredTailwindV4CssRoots({
|
|
5625
5766
|
...options,
|
|
@@ -5955,7 +6096,8 @@ function WeappTailwindcss(options = {}) {
|
|
|
5955
6096
|
getExtraOptions: (file) => ({
|
|
5956
6097
|
...resolveViteCssHandlerExtraOptions(file),
|
|
5957
6098
|
...resolveUniAppXNativeCssHandlerOptions(opts)
|
|
5958
|
-
})
|
|
6099
|
+
}),
|
|
6100
|
+
getDynamicCssOptions: () => ({ cssPreflight: opts.cssPreflight })
|
|
5959
6101
|
});
|
|
5960
6102
|
const serveJsHandlerOptions = createJsHandlerOptionsFactory({
|
|
5961
6103
|
getMajorVersion: () => runtimeState.tailwindRuntime.majorVersion,
|
|
@@ -6002,7 +6144,7 @@ function WeappTailwindcss(options = {}) {
|
|
|
6002
6144
|
deferEmptyScopedCssSource: shouldDeferEmptyScopedCssSource
|
|
6003
6145
|
});
|
|
6004
6146
|
if (!generated) return;
|
|
6005
|
-
const tracedCss = annotateCssSourceTrace(generated.css, {
|
|
6147
|
+
const tracedCss = annotateCssSourceTrace(finalizeViteMiniProgramCss(generated.css), {
|
|
6006
6148
|
opts,
|
|
6007
6149
|
tokenSources: createCssTokenSourceMap(getSourceCandidateSourcesForEntries(void 0), opts)
|
|
6008
6150
|
});
|
|
@@ -6126,20 +6268,45 @@ function WeappTailwindcss(options = {}) {
|
|
|
6126
6268
|
{
|
|
6127
6269
|
name: `${vitePluginName}:source-candidates`,
|
|
6128
6270
|
enforce: "pre",
|
|
6129
|
-
async
|
|
6130
|
-
if (shouldOwnTailwindGeneration)
|
|
6131
|
-
|
|
6132
|
-
|
|
6133
|
-
|
|
6134
|
-
|
|
6135
|
-
|
|
6136
|
-
|
|
6137
|
-
|
|
6271
|
+
async load(id) {
|
|
6272
|
+
if (!shouldOwnTailwindGeneration || isWebOrNativeAppPlatform(resolveViteStylePlatform()) || !isCSSRequest(id) || !shouldCollectTransformedSourceCandidates(id)) return;
|
|
6273
|
+
const rawCode = await readFile(cleanUrl(id), "utf8").catch(() => void 0);
|
|
6274
|
+
if (typeof rawCode !== "string") return;
|
|
6275
|
+
const transformedCode = transformEarlyMiniProgramCss(rawCode);
|
|
6276
|
+
if (transformedCode === rawCode) return;
|
|
6277
|
+
cssMemory.rememberKnownSfcSource(id, transformedCode);
|
|
6278
|
+
return transformedCode;
|
|
6279
|
+
},
|
|
6280
|
+
transform: {
|
|
6281
|
+
order: "pre",
|
|
6282
|
+
async handler(code, id) {
|
|
6283
|
+
let transformedCode = code;
|
|
6284
|
+
if (shouldOwnTailwindGeneration && !generatorBranch.isWeb && isCSSRequest(id)) transformedCode = transformEarlyMiniProgramCss(code);
|
|
6285
|
+
const shouldReturnTransformedCode = transformedCode !== code;
|
|
6286
|
+
if (shouldOwnTailwindGeneration) cssMemory.rememberKnownSfcSource(id, transformedCode);
|
|
6287
|
+
if (!shouldOwnTailwindGeneration || !isSourceCandidateRequest(id) || !shouldCollectTransformedSourceCandidates(id)) {
|
|
6288
|
+
if (shouldReturnTransformedCode) return {
|
|
6289
|
+
code: transformedCode,
|
|
6290
|
+
map: null
|
|
6291
|
+
};
|
|
6138
6292
|
return;
|
|
6139
6293
|
}
|
|
6140
|
-
|
|
6141
|
-
|
|
6142
|
-
|
|
6294
|
+
return hmrTimingRecorder.measure("sourceCandidates.transform", async () => {
|
|
6295
|
+
invalidateRecordedGeneratorCandidates();
|
|
6296
|
+
const file = cleanUrl(id);
|
|
6297
|
+
if (sourceScanMatcher && !sourceScanMatcher(file)) {
|
|
6298
|
+
sourceCandidateCollector.remove(file);
|
|
6299
|
+
cacheCurrentSourceCandidateScan();
|
|
6300
|
+
return;
|
|
6301
|
+
}
|
|
6302
|
+
await sourceCandidateCollector.merge(id, transformedCode);
|
|
6303
|
+
cacheCurrentSourceCandidateScan();
|
|
6304
|
+
if (shouldReturnTransformedCode) return {
|
|
6305
|
+
code: transformedCode,
|
|
6306
|
+
map: null
|
|
6307
|
+
};
|
|
6308
|
+
}, { emit: false });
|
|
6309
|
+
}
|
|
6143
6310
|
},
|
|
6144
6311
|
async watchChange(id, change) {
|
|
6145
6312
|
await hmrTimingRecorder.measure("sourceCandidates.watchChange", async () => {
|
|
@@ -6227,6 +6394,7 @@ function WeappTailwindcss(options = {}) {
|
|
|
6227
6394
|
if (opts.tailwindcssBasedir !== nextTailwindcssBasedir) {
|
|
6228
6395
|
const previousBasedir = opts.tailwindcssBasedir;
|
|
6229
6396
|
opts.tailwindcssBasedir = nextTailwindcssBasedir;
|
|
6397
|
+
shouldRefreshRuntime = syncCssEntriesFromAnchor(nextTailwindcssBasedir) || shouldRefreshRuntime;
|
|
6230
6398
|
debug("align tailwindcss basedir with vite root: %s -> %s", previousBasedir ?? "undefined", nextTailwindcssBasedir);
|
|
6231
6399
|
shouldRefreshRuntime = true;
|
|
6232
6400
|
}
|