weapp-tailwindcss 5.0.0-next.15 → 5.0.0-next.17
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/{bundle-state-ClSg28Qk.js → bundle-state-DDgxuERW.js} +1 -1
- package/dist/{bundle-state-CrhkNTsw.mjs → bundle-state-YW-zLcsc.mjs} +1 -1
- package/dist/bundlers/shared/css-cleanup/root-cleanups.d.ts +1 -0
- package/dist/bundlers/shared/generator-css/markers.d.ts +4 -0
- package/dist/bundlers/shared/generator-css.d.ts +1 -1
- package/dist/bundlers/vite/css-finalizer.d.ts +1 -0
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/{generator-CImaTibB.js → generator-BIEhxFdv.js} +1 -1
- package/dist/{generator-DSMdL4vg.mjs → generator-Ber8UVgv.mjs} +1 -1
- package/dist/generator.js +2 -2
- package/dist/generator.mjs +2 -2
- package/dist/gulp.js +5 -5
- package/dist/gulp.mjs +5 -5
- package/dist/{incremental-runtime-class-set-CH1L--wj.js → incremental-runtime-class-set-CfznDtJ0.js} +134 -21
- package/dist/{incremental-runtime-class-set-P-3ZoWW5.mjs → incremental-runtime-class-set-DC0RsBbK.mjs} +134 -21
- package/dist/index.js +4 -4
- package/dist/index.mjs +4 -4
- package/dist/{postcss-k0BshZZQ.js → postcss-DCOUtuwI.js} +2 -2
- package/dist/{postcss-CgFCqilE.mjs → postcss-DW08tZXt.mjs} +2 -2
- package/dist/postcss.js +1 -1
- package/dist/postcss.mjs +1 -1
- package/dist/{precheck-DMXLnfTN.mjs → precheck-CX-5VqM1.mjs} +2 -2
- package/dist/{precheck-GcUdX1BX.js → precheck-CZfnh4T6.js} +2 -2
- package/dist/presets.js +2 -2
- package/dist/presets.mjs +2 -2
- package/dist/{source-candidates-ES3ttZPe.js → source-candidates-BDyoPviV.js} +1 -1
- package/dist/{source-candidates-om5-wQJ0.mjs → source-candidates-DGlDzkvf.mjs} +1 -1
- package/dist/{tailwindcss-CkTBauKa.js → tailwindcss-BVoa7vx-.js} +5 -3
- package/dist/{tailwindcss-fe0rGj7T.mjs → tailwindcss-D74Wk4ys.mjs} +5 -3
- package/dist/{v3-engine-v__n8_Sd.js → v3-engine-BRInt2DS.js} +92 -4
- package/dist/{v3-engine-qoWtwjIj.mjs → v3-engine-CCxDqZ8e.mjs} +93 -5
- package/dist/{vite-Bob_Mrva.js → vite-DnHdmHHD.js} +32 -15
- package/dist/{vite-cBjGYHFH.mjs → vite-bmU2kkO6.mjs} +32 -15
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.js +2 -1
- package/dist/{webpack-Cq45BZzs.mjs → webpack-BkBoEn4k.mjs} +5 -5
- package/dist/{webpack-BedfyGbF.js → webpack-SxEdWHlL.js} +5 -5
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +4 -4
|
@@ -662,6 +662,7 @@ function removeUnsupportedCascadeLayers(root) {
|
|
|
662
662
|
//#endregion
|
|
663
663
|
//#region src/tailwindcss/miniprogram.ts
|
|
664
664
|
const DEFAULT_WEAPP_VARIABLE_SCOPE = "page,.tw-root,wx-root-portal-content,:host";
|
|
665
|
+
const DEFAULT_WEAPP_ELEMENT_VARIABLE_SCOPE = "view,text,:before,:after";
|
|
665
666
|
const CLASS_SELECTOR_RE = /(?:^|[^\w-])\.[_a-z\u00A0-\uFFFF\\-]/i;
|
|
666
667
|
const PSEUDO_CONTENT_SELECTOR_RE = /^(?:::before|::after|:before|:after)(?:,(?:::before|::after|:before|:after))*$/;
|
|
667
668
|
const MINI_PROGRAM_THEME_SCOPE_SELECTORS = new Set([
|
|
@@ -671,6 +672,14 @@ const MINI_PROGRAM_THEME_SCOPE_SELECTORS = new Set([
|
|
|
671
672
|
".tw-root",
|
|
672
673
|
"wx-root-portal-content"
|
|
673
674
|
]);
|
|
675
|
+
const MINI_PROGRAM_ELEMENT_VARIABLE_SCOPE_SELECTORS = new Set([
|
|
676
|
+
"view",
|
|
677
|
+
"text",
|
|
678
|
+
":before",
|
|
679
|
+
":after",
|
|
680
|
+
"::before",
|
|
681
|
+
"::after"
|
|
682
|
+
]);
|
|
674
683
|
const MINI_PROGRAM_PREFLIGHT_SELECTORS = new Set([
|
|
675
684
|
"*",
|
|
676
685
|
"view",
|
|
@@ -749,6 +758,27 @@ function isMiniProgramThemeScopeRule(rule) {
|
|
|
749
758
|
const selectors = getRuleSelectors(rule);
|
|
750
759
|
return selectors.length > 0 && selectors.every((selector) => MINI_PROGRAM_THEME_SCOPE_SELECTORS.has(selector));
|
|
751
760
|
}
|
|
761
|
+
function isMiniProgramElementVariableScopeRule(rule) {
|
|
762
|
+
const selectors = getRuleSelectors(rule);
|
|
763
|
+
return selectors.length > 0 && selectors.every((selector) => MINI_PROGRAM_ELEMENT_VARIABLE_SCOPE_SELECTORS.has(selector));
|
|
764
|
+
}
|
|
765
|
+
function isTailwindV4GradientRuntimeDeclaration(decl) {
|
|
766
|
+
return decl.prop.startsWith("--tw-gradient-");
|
|
767
|
+
}
|
|
768
|
+
function moveTailwindV4GradientRuntimeDeclarations(rule) {
|
|
769
|
+
const gradientDeclarations = [];
|
|
770
|
+
rule.walkDecls((decl) => {
|
|
771
|
+
if (isTailwindV4GradientRuntimeDeclaration(decl)) {
|
|
772
|
+
gradientDeclarations.push(decl.clone());
|
|
773
|
+
decl.remove();
|
|
774
|
+
}
|
|
775
|
+
});
|
|
776
|
+
if (gradientDeclarations.length > 0) rule.before(new postcss.default.Rule({
|
|
777
|
+
selector: DEFAULT_WEAPP_ELEMENT_VARIABLE_SCOPE,
|
|
778
|
+
nodes: gradientDeclarations
|
|
779
|
+
}));
|
|
780
|
+
if (rule.nodes.length === 0) rule.remove();
|
|
781
|
+
}
|
|
752
782
|
function isKeyframesRule(rule) {
|
|
753
783
|
let parent = rule.parent;
|
|
754
784
|
while (parent) {
|
|
@@ -757,6 +787,25 @@ function isKeyframesRule(rule) {
|
|
|
757
787
|
}
|
|
758
788
|
return false;
|
|
759
789
|
}
|
|
790
|
+
function removeDeclarationAndEmptyRule(decl) {
|
|
791
|
+
const parent = decl.parent;
|
|
792
|
+
decl.remove();
|
|
793
|
+
if (parent?.type === "rule" && parent.nodes.length === 0) parent.remove();
|
|
794
|
+
}
|
|
795
|
+
function normalizeMiniProgramColorValues(root) {
|
|
796
|
+
const customPropertyValues = /* @__PURE__ */ new Map();
|
|
797
|
+
root.walkDecls((decl) => {
|
|
798
|
+
if (decl.prop.startsWith("--")) customPropertyValues.set(decl.prop, decl.value.trim());
|
|
799
|
+
});
|
|
800
|
+
root.walkDecls((decl) => {
|
|
801
|
+
const normalized = (0, _weapp_tailwindcss_postcss.normalizeModernColorValue)(decl.value, customPropertyValues);
|
|
802
|
+
if (normalized.changed) {
|
|
803
|
+
decl.value = normalized.value;
|
|
804
|
+
if (decl.prop.startsWith("--")) customPropertyValues.set(decl.prop, decl.value.trim());
|
|
805
|
+
}
|
|
806
|
+
if (normalized.hasUnsupported) removeDeclarationAndEmptyRule(decl);
|
|
807
|
+
});
|
|
808
|
+
}
|
|
760
809
|
/**
|
|
761
810
|
* 裁剪 Tailwind 生成 CSS 中面向浏览器的 classless 规则。
|
|
762
811
|
*
|
|
@@ -770,12 +819,19 @@ function pruneMiniProgramGeneratedCss(css, options = {}) {
|
|
|
770
819
|
comment.remove();
|
|
771
820
|
});
|
|
772
821
|
removeUnsupportedCascadeLayers(root);
|
|
822
|
+
normalizeMiniProgramColorValues(root);
|
|
773
823
|
root.walkAtRules("supports", (atRule) => {
|
|
774
824
|
atRule.remove();
|
|
775
825
|
});
|
|
776
826
|
root.walkRules((rule) => {
|
|
777
827
|
if (isKeyframesRule(rule)) return;
|
|
828
|
+
if (isCustomPropertyRule(rule) && isMiniProgramElementVariableScopeRule(rule)) {
|
|
829
|
+
rule.selector = DEFAULT_WEAPP_ELEMENT_VARIABLE_SCOPE;
|
|
830
|
+
return;
|
|
831
|
+
}
|
|
778
832
|
if (isCustomPropertyRule(rule) && isMiniProgramThemeScopeRule(rule)) {
|
|
833
|
+
moveTailwindV4GradientRuntimeDeclarations(rule);
|
|
834
|
+
if (!rule.parent) return;
|
|
779
835
|
rule.selector = DEFAULT_WEAPP_VARIABLE_SCOPE;
|
|
780
836
|
return;
|
|
781
837
|
}
|
|
@@ -787,6 +843,8 @@ function pruneMiniProgramGeneratedCss(css, options = {}) {
|
|
|
787
843
|
}
|
|
788
844
|
if (options.preservePreflight && isMiniProgramPreflightRule(rule)) return;
|
|
789
845
|
if (isCustomPropertyRule(rule)) {
|
|
846
|
+
moveTailwindV4GradientRuntimeDeclarations(rule);
|
|
847
|
+
if (!rule.parent) return;
|
|
790
848
|
rule.selector = DEFAULT_WEAPP_VARIABLE_SCOPE;
|
|
791
849
|
return;
|
|
792
850
|
}
|
|
@@ -816,7 +874,7 @@ function normalizeTailwindV4GeneratedUrlValues(css) {
|
|
|
816
874
|
});
|
|
817
875
|
}
|
|
818
876
|
async function transformTailwindV4CssToWeapp(css, options) {
|
|
819
|
-
const protectedCss = (0, _weapp_tailwindcss_postcss.protectDynamicColorMixAlpha)(normalizeTailwindV4GeneratedUrlValues(css));
|
|
877
|
+
const protectedCss = (0, _weapp_tailwindcss_postcss.protectDynamicColorMixAlpha)(normalizeTailwindV4GeneratedUrlValues(css), { customPropertyValues: options && "customPropertyValues" in options ? options.customPropertyValues : void 0 });
|
|
820
878
|
const result = await defaultStyleHandler$1(protectedCss.css, {
|
|
821
879
|
cssChildCombinatorReplaceValue: ["view", "text"],
|
|
822
880
|
cssRemoveHoverPseudoClass: true,
|
|
@@ -1659,13 +1717,34 @@ function collectSeenCandidates(generated, requestedCandidates) {
|
|
|
1659
1717
|
...generated.classSet
|
|
1660
1718
|
]);
|
|
1661
1719
|
}
|
|
1720
|
+
function createIncrementalStyleOptions(styleOptions) {
|
|
1721
|
+
return {
|
|
1722
|
+
...styleOptions,
|
|
1723
|
+
isMainChunk: false
|
|
1724
|
+
};
|
|
1725
|
+
}
|
|
1726
|
+
function collectCustomPropertyValues(css) {
|
|
1727
|
+
const values = /* @__PURE__ */ new Map();
|
|
1728
|
+
try {
|
|
1729
|
+
postcss.default.parse(css).walkDecls((decl) => {
|
|
1730
|
+
if (decl.prop.startsWith("--")) values.set(decl.prop, decl.value.trim());
|
|
1731
|
+
});
|
|
1732
|
+
} catch {}
|
|
1733
|
+
return values;
|
|
1734
|
+
}
|
|
1735
|
+
function mergeCustomPropertyValues(target, css) {
|
|
1736
|
+
for (const [prop, value] of collectCustomPropertyValues(css)) target.set(prop, value);
|
|
1737
|
+
}
|
|
1662
1738
|
function seedIncrementalGenerateCache(options) {
|
|
1663
1739
|
const cacheKey = createIncrementalGenerateCacheKey$1(options.compatibleSource, options.target, options.styleOptions, options.tailwindcssV3Compatibility);
|
|
1740
|
+
const customPropertyValues = collectCustomPropertyValues(options.compatibleSource.css);
|
|
1741
|
+
mergeCustomPropertyValues(customPropertyValues, options.generated.css);
|
|
1664
1742
|
incrementalGenerateCache$1.set(cacheKey, {
|
|
1665
1743
|
seenCandidates: collectSeenCandidates(options.generated, options.requestedCandidates),
|
|
1666
1744
|
classSet: new Set(options.generated.classSet),
|
|
1667
1745
|
css: options.generated.css,
|
|
1668
1746
|
rawCss: options.generated.rawCss,
|
|
1747
|
+
customPropertyValues,
|
|
1669
1748
|
designSystemPromise: createIncrementalDesignSystemPromise(options.compatibleSource, cacheKey),
|
|
1670
1749
|
dependencies: options.generated.dependencies,
|
|
1671
1750
|
sources: options.generated.sources,
|
|
@@ -1865,11 +1944,15 @@ function createTailwindV4Engine(source) {
|
|
|
1865
1944
|
}
|
|
1866
1945
|
}
|
|
1867
1946
|
const rawCss = rawCssParts.join("\n");
|
|
1868
|
-
const incrementalCss = rawCss.length > 0 ? await transformTailwindV4CssByTarget(rawCss, target,
|
|
1947
|
+
const incrementalCss = rawCss.length > 0 ? await transformTailwindV4CssByTarget(rawCss, target, {
|
|
1948
|
+
...createIncrementalStyleOptions(options.styleOptions),
|
|
1949
|
+
customPropertyValues: cached.customPropertyValues
|
|
1950
|
+
}) : "";
|
|
1869
1951
|
for (const candidate of missingCandidates) cached.seenCandidates.add(candidate);
|
|
1870
1952
|
for (const className of classSet) cached.classSet.add(className);
|
|
1871
1953
|
cached.css = [cached.css, incrementalCss].filter(Boolean).join("\n");
|
|
1872
1954
|
cached.rawCss = [cached.rawCss, rawCss].filter(Boolean).join("\n");
|
|
1955
|
+
mergeCustomPropertyValues(cached.customPropertyValues, incrementalCss);
|
|
1873
1956
|
return {
|
|
1874
1957
|
css: cached.css,
|
|
1875
1958
|
rawCss: cached.rawCss,
|
|
@@ -2760,7 +2843,12 @@ const defaultStyleHandler = (0, _weapp_tailwindcss_postcss.createStyleHandler)({
|
|
|
2760
2843
|
isMainChunk: true,
|
|
2761
2844
|
majorVersion: 3
|
|
2762
2845
|
});
|
|
2763
|
-
const
|
|
2846
|
+
const MINI_PROGRAM_V3_PREFLIGHT_SELECTORS = new Set([
|
|
2847
|
+
"view,text,:before,:after",
|
|
2848
|
+
"view,text,:after,:before",
|
|
2849
|
+
"view,text,::before,::after",
|
|
2850
|
+
"view,text,::after,::before"
|
|
2851
|
+
]);
|
|
2764
2852
|
const V3_PREFLIGHT_RESET_PROPS = new Set([
|
|
2765
2853
|
"box-sizing",
|
|
2766
2854
|
"border",
|
|
@@ -2774,7 +2862,7 @@ function normalizeSelector(selector) {
|
|
|
2774
2862
|
return selector.trim().replace(/\s+/g, "");
|
|
2775
2863
|
}
|
|
2776
2864
|
function isMiniProgramV3PreflightRule(rule) {
|
|
2777
|
-
return normalizeSelector(rule.selector)
|
|
2865
|
+
return MINI_PROGRAM_V3_PREFLIGHT_SELECTORS.has(normalizeSelector(rule.selector));
|
|
2778
2866
|
}
|
|
2779
2867
|
function hasResetDeclaration(rule) {
|
|
2780
2868
|
let found = false;
|
|
@@ -12,7 +12,7 @@ import { stat } from "node:fs/promises";
|
|
|
12
12
|
import fg from "fast-glob";
|
|
13
13
|
import micromatch from "micromatch";
|
|
14
14
|
import { loadConfig } from "tailwindcss-config";
|
|
15
|
-
import { createStyleHandler, protectDynamicColorMixAlpha } from "@weapp-tailwindcss/postcss";
|
|
15
|
+
import { createStyleHandler, normalizeModernColorValue, protectDynamicColorMixAlpha } from "@weapp-tailwindcss/postcss";
|
|
16
16
|
//#region src/context/workspace.ts
|
|
17
17
|
const IGNORED_WORKSPACE_DIRS = new Set([
|
|
18
18
|
"node_modules",
|
|
@@ -654,6 +654,7 @@ function removeUnsupportedCascadeLayers(root) {
|
|
|
654
654
|
//#endregion
|
|
655
655
|
//#region src/tailwindcss/miniprogram.ts
|
|
656
656
|
const DEFAULT_WEAPP_VARIABLE_SCOPE = "page,.tw-root,wx-root-portal-content,:host";
|
|
657
|
+
const DEFAULT_WEAPP_ELEMENT_VARIABLE_SCOPE = "view,text,:before,:after";
|
|
657
658
|
const CLASS_SELECTOR_RE = /(?:^|[^\w-])\.[_a-z\u00A0-\uFFFF\\-]/i;
|
|
658
659
|
const PSEUDO_CONTENT_SELECTOR_RE = /^(?:::before|::after|:before|:after)(?:,(?:::before|::after|:before|:after))*$/;
|
|
659
660
|
const MINI_PROGRAM_THEME_SCOPE_SELECTORS = new Set([
|
|
@@ -663,6 +664,14 @@ const MINI_PROGRAM_THEME_SCOPE_SELECTORS = new Set([
|
|
|
663
664
|
".tw-root",
|
|
664
665
|
"wx-root-portal-content"
|
|
665
666
|
]);
|
|
667
|
+
const MINI_PROGRAM_ELEMENT_VARIABLE_SCOPE_SELECTORS = new Set([
|
|
668
|
+
"view",
|
|
669
|
+
"text",
|
|
670
|
+
":before",
|
|
671
|
+
":after",
|
|
672
|
+
"::before",
|
|
673
|
+
"::after"
|
|
674
|
+
]);
|
|
666
675
|
const MINI_PROGRAM_PREFLIGHT_SELECTORS = new Set([
|
|
667
676
|
"*",
|
|
668
677
|
"view",
|
|
@@ -741,6 +750,27 @@ function isMiniProgramThemeScopeRule(rule) {
|
|
|
741
750
|
const selectors = getRuleSelectors(rule);
|
|
742
751
|
return selectors.length > 0 && selectors.every((selector) => MINI_PROGRAM_THEME_SCOPE_SELECTORS.has(selector));
|
|
743
752
|
}
|
|
753
|
+
function isMiniProgramElementVariableScopeRule(rule) {
|
|
754
|
+
const selectors = getRuleSelectors(rule);
|
|
755
|
+
return selectors.length > 0 && selectors.every((selector) => MINI_PROGRAM_ELEMENT_VARIABLE_SCOPE_SELECTORS.has(selector));
|
|
756
|
+
}
|
|
757
|
+
function isTailwindV4GradientRuntimeDeclaration(decl) {
|
|
758
|
+
return decl.prop.startsWith("--tw-gradient-");
|
|
759
|
+
}
|
|
760
|
+
function moveTailwindV4GradientRuntimeDeclarations(rule) {
|
|
761
|
+
const gradientDeclarations = [];
|
|
762
|
+
rule.walkDecls((decl) => {
|
|
763
|
+
if (isTailwindV4GradientRuntimeDeclaration(decl)) {
|
|
764
|
+
gradientDeclarations.push(decl.clone());
|
|
765
|
+
decl.remove();
|
|
766
|
+
}
|
|
767
|
+
});
|
|
768
|
+
if (gradientDeclarations.length > 0) rule.before(new postcss.Rule({
|
|
769
|
+
selector: DEFAULT_WEAPP_ELEMENT_VARIABLE_SCOPE,
|
|
770
|
+
nodes: gradientDeclarations
|
|
771
|
+
}));
|
|
772
|
+
if (rule.nodes.length === 0) rule.remove();
|
|
773
|
+
}
|
|
744
774
|
function isKeyframesRule(rule) {
|
|
745
775
|
let parent = rule.parent;
|
|
746
776
|
while (parent) {
|
|
@@ -749,6 +779,25 @@ function isKeyframesRule(rule) {
|
|
|
749
779
|
}
|
|
750
780
|
return false;
|
|
751
781
|
}
|
|
782
|
+
function removeDeclarationAndEmptyRule(decl) {
|
|
783
|
+
const parent = decl.parent;
|
|
784
|
+
decl.remove();
|
|
785
|
+
if (parent?.type === "rule" && parent.nodes.length === 0) parent.remove();
|
|
786
|
+
}
|
|
787
|
+
function normalizeMiniProgramColorValues(root) {
|
|
788
|
+
const customPropertyValues = /* @__PURE__ */ new Map();
|
|
789
|
+
root.walkDecls((decl) => {
|
|
790
|
+
if (decl.prop.startsWith("--")) customPropertyValues.set(decl.prop, decl.value.trim());
|
|
791
|
+
});
|
|
792
|
+
root.walkDecls((decl) => {
|
|
793
|
+
const normalized = normalizeModernColorValue(decl.value, customPropertyValues);
|
|
794
|
+
if (normalized.changed) {
|
|
795
|
+
decl.value = normalized.value;
|
|
796
|
+
if (decl.prop.startsWith("--")) customPropertyValues.set(decl.prop, decl.value.trim());
|
|
797
|
+
}
|
|
798
|
+
if (normalized.hasUnsupported) removeDeclarationAndEmptyRule(decl);
|
|
799
|
+
});
|
|
800
|
+
}
|
|
752
801
|
/**
|
|
753
802
|
* 裁剪 Tailwind 生成 CSS 中面向浏览器的 classless 规则。
|
|
754
803
|
*
|
|
@@ -762,12 +811,19 @@ function pruneMiniProgramGeneratedCss(css, options = {}) {
|
|
|
762
811
|
comment.remove();
|
|
763
812
|
});
|
|
764
813
|
removeUnsupportedCascadeLayers(root);
|
|
814
|
+
normalizeMiniProgramColorValues(root);
|
|
765
815
|
root.walkAtRules("supports", (atRule) => {
|
|
766
816
|
atRule.remove();
|
|
767
817
|
});
|
|
768
818
|
root.walkRules((rule) => {
|
|
769
819
|
if (isKeyframesRule(rule)) return;
|
|
820
|
+
if (isCustomPropertyRule(rule) && isMiniProgramElementVariableScopeRule(rule)) {
|
|
821
|
+
rule.selector = DEFAULT_WEAPP_ELEMENT_VARIABLE_SCOPE;
|
|
822
|
+
return;
|
|
823
|
+
}
|
|
770
824
|
if (isCustomPropertyRule(rule) && isMiniProgramThemeScopeRule(rule)) {
|
|
825
|
+
moveTailwindV4GradientRuntimeDeclarations(rule);
|
|
826
|
+
if (!rule.parent) return;
|
|
771
827
|
rule.selector = DEFAULT_WEAPP_VARIABLE_SCOPE;
|
|
772
828
|
return;
|
|
773
829
|
}
|
|
@@ -779,6 +835,8 @@ function pruneMiniProgramGeneratedCss(css, options = {}) {
|
|
|
779
835
|
}
|
|
780
836
|
if (options.preservePreflight && isMiniProgramPreflightRule(rule)) return;
|
|
781
837
|
if (isCustomPropertyRule(rule)) {
|
|
838
|
+
moveTailwindV4GradientRuntimeDeclarations(rule);
|
|
839
|
+
if (!rule.parent) return;
|
|
782
840
|
rule.selector = DEFAULT_WEAPP_VARIABLE_SCOPE;
|
|
783
841
|
return;
|
|
784
842
|
}
|
|
@@ -808,7 +866,7 @@ function normalizeTailwindV4GeneratedUrlValues(css) {
|
|
|
808
866
|
});
|
|
809
867
|
}
|
|
810
868
|
async function transformTailwindV4CssToWeapp(css, options) {
|
|
811
|
-
const protectedCss = protectDynamicColorMixAlpha(normalizeTailwindV4GeneratedUrlValues(css));
|
|
869
|
+
const protectedCss = protectDynamicColorMixAlpha(normalizeTailwindV4GeneratedUrlValues(css), { customPropertyValues: options && "customPropertyValues" in options ? options.customPropertyValues : void 0 });
|
|
812
870
|
const result = await defaultStyleHandler$1(protectedCss.css, {
|
|
813
871
|
cssChildCombinatorReplaceValue: ["view", "text"],
|
|
814
872
|
cssRemoveHoverPseudoClass: true,
|
|
@@ -1651,13 +1709,34 @@ function collectSeenCandidates(generated, requestedCandidates) {
|
|
|
1651
1709
|
...generated.classSet
|
|
1652
1710
|
]);
|
|
1653
1711
|
}
|
|
1712
|
+
function createIncrementalStyleOptions(styleOptions) {
|
|
1713
|
+
return {
|
|
1714
|
+
...styleOptions,
|
|
1715
|
+
isMainChunk: false
|
|
1716
|
+
};
|
|
1717
|
+
}
|
|
1718
|
+
function collectCustomPropertyValues(css) {
|
|
1719
|
+
const values = /* @__PURE__ */ new Map();
|
|
1720
|
+
try {
|
|
1721
|
+
postcss.parse(css).walkDecls((decl) => {
|
|
1722
|
+
if (decl.prop.startsWith("--")) values.set(decl.prop, decl.value.trim());
|
|
1723
|
+
});
|
|
1724
|
+
} catch {}
|
|
1725
|
+
return values;
|
|
1726
|
+
}
|
|
1727
|
+
function mergeCustomPropertyValues(target, css) {
|
|
1728
|
+
for (const [prop, value] of collectCustomPropertyValues(css)) target.set(prop, value);
|
|
1729
|
+
}
|
|
1654
1730
|
function seedIncrementalGenerateCache(options) {
|
|
1655
1731
|
const cacheKey = createIncrementalGenerateCacheKey$1(options.compatibleSource, options.target, options.styleOptions, options.tailwindcssV3Compatibility);
|
|
1732
|
+
const customPropertyValues = collectCustomPropertyValues(options.compatibleSource.css);
|
|
1733
|
+
mergeCustomPropertyValues(customPropertyValues, options.generated.css);
|
|
1656
1734
|
incrementalGenerateCache$1.set(cacheKey, {
|
|
1657
1735
|
seenCandidates: collectSeenCandidates(options.generated, options.requestedCandidates),
|
|
1658
1736
|
classSet: new Set(options.generated.classSet),
|
|
1659
1737
|
css: options.generated.css,
|
|
1660
1738
|
rawCss: options.generated.rawCss,
|
|
1739
|
+
customPropertyValues,
|
|
1661
1740
|
designSystemPromise: createIncrementalDesignSystemPromise(options.compatibleSource, cacheKey),
|
|
1662
1741
|
dependencies: options.generated.dependencies,
|
|
1663
1742
|
sources: options.generated.sources,
|
|
@@ -1857,11 +1936,15 @@ function createTailwindV4Engine$1(source) {
|
|
|
1857
1936
|
}
|
|
1858
1937
|
}
|
|
1859
1938
|
const rawCss = rawCssParts.join("\n");
|
|
1860
|
-
const incrementalCss = rawCss.length > 0 ? await transformTailwindV4CssByTarget(rawCss, target,
|
|
1939
|
+
const incrementalCss = rawCss.length > 0 ? await transformTailwindV4CssByTarget(rawCss, target, {
|
|
1940
|
+
...createIncrementalStyleOptions(options.styleOptions),
|
|
1941
|
+
customPropertyValues: cached.customPropertyValues
|
|
1942
|
+
}) : "";
|
|
1861
1943
|
for (const candidate of missingCandidates) cached.seenCandidates.add(candidate);
|
|
1862
1944
|
for (const className of classSet) cached.classSet.add(className);
|
|
1863
1945
|
cached.css = [cached.css, incrementalCss].filter(Boolean).join("\n");
|
|
1864
1946
|
cached.rawCss = [cached.rawCss, rawCss].filter(Boolean).join("\n");
|
|
1947
|
+
mergeCustomPropertyValues(cached.customPropertyValues, incrementalCss);
|
|
1865
1948
|
return {
|
|
1866
1949
|
css: cached.css,
|
|
1867
1950
|
rawCss: cached.rawCss,
|
|
@@ -2752,7 +2835,12 @@ const defaultStyleHandler = createStyleHandler({
|
|
|
2752
2835
|
isMainChunk: true,
|
|
2753
2836
|
majorVersion: 3
|
|
2754
2837
|
});
|
|
2755
|
-
const
|
|
2838
|
+
const MINI_PROGRAM_V3_PREFLIGHT_SELECTORS = new Set([
|
|
2839
|
+
"view,text,:before,:after",
|
|
2840
|
+
"view,text,:after,:before",
|
|
2841
|
+
"view,text,::before,::after",
|
|
2842
|
+
"view,text,::after,::before"
|
|
2843
|
+
]);
|
|
2756
2844
|
const V3_PREFLIGHT_RESET_PROPS = new Set([
|
|
2757
2845
|
"box-sizing",
|
|
2758
2846
|
"border",
|
|
@@ -2766,7 +2854,7 @@ function normalizeSelector(selector) {
|
|
|
2766
2854
|
return selector.trim().replace(/\s+/g, "");
|
|
2767
2855
|
}
|
|
2768
2856
|
function isMiniProgramV3PreflightRule(rule) {
|
|
2769
|
-
return normalizeSelector(rule.selector)
|
|
2857
|
+
return MINI_PROGRAM_V3_PREFLIGHT_SELECTORS.has(normalizeSelector(rule.selector));
|
|
2770
2858
|
}
|
|
2771
2859
|
function hasResetDeclaration(rule) {
|
|
2772
2860
|
let found = false;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-8l464Juk.js");
|
|
2
|
-
const require_v3_engine = require("./v3-engine-
|
|
3
|
-
const require_generator = require("./generator-
|
|
4
|
-
const require_incremental_runtime_class_set = require("./incremental-runtime-class-set-
|
|
5
|
-
const require_precheck = require("./precheck-
|
|
2
|
+
const require_v3_engine = require("./v3-engine-BRInt2DS.js");
|
|
3
|
+
const require_generator = require("./generator-BIEhxFdv.js");
|
|
4
|
+
const require_incremental_runtime_class_set = require("./incremental-runtime-class-set-CfznDtJ0.js");
|
|
5
|
+
const require_precheck = require("./precheck-CZfnh4T6.js");
|
|
6
6
|
const require_utils = require("./utils-4ODFyoqD.js");
|
|
7
|
-
const require_tailwindcss = require("./tailwindcss-
|
|
8
|
-
const require_source_candidates = require("./source-candidates-
|
|
9
|
-
const require_bundle_state = require("./bundle-state-
|
|
7
|
+
const require_tailwindcss = require("./tailwindcss-BVoa7vx-.js");
|
|
8
|
+
const require_source_candidates = require("./source-candidates-BDyoPviV.js");
|
|
9
|
+
const require_bundle_state = require("./bundle-state-DDgxuERW.js");
|
|
10
10
|
require("./logger-EVNB9z7i.js");
|
|
11
11
|
let node_fs = require("node:fs");
|
|
12
12
|
node_fs = require_chunk.__toESM(node_fs);
|
|
@@ -534,6 +534,7 @@ function createCssHandlerOptions(opts, majorVersion, file) {
|
|
|
534
534
|
}
|
|
535
535
|
function shouldGenerateCssByGenerator(opts, file, rawSource, processed) {
|
|
536
536
|
const generatorOptions = require_generator.normalizeWeappTailwindcssGeneratorOptions(opts.generator);
|
|
537
|
+
if (generatorOptions.target === "web") return false;
|
|
537
538
|
if (require_incremental_runtime_class_set.hasTailwindGeneratedCssMarkers(rawSource) || require_incremental_runtime_class_set.hasTailwindSourceDirectives(rawSource, { importFallback: generatorOptions.importFallback })) return true;
|
|
538
539
|
if (opts.twPatcher.majorVersion === 3) return false;
|
|
539
540
|
return processed && shouldFinalizeProcessedCssAsset(opts, file);
|
|
@@ -547,7 +548,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
547
548
|
generateBundle: {
|
|
548
549
|
order: "post",
|
|
549
550
|
async handler(_options, bundle) {
|
|
550
|
-
const { opts, runtimeState, ensureRuntimeClassSet, isCssAssetProcessed, markCssAssetProcessed, debug, getResolvedConfig, recordCssAssetResult, getRecordedGeneratorCandidates, getSourceCandidates, getSourceCandidatesForEntries, waitForSourceCandidateSyncs, rememberMainCssSource } = context;
|
|
551
|
+
const { opts, runtimeState, ensureRuntimeClassSet, isCssAssetProcessed, markCssAssetProcessed, debug, getResolvedConfig, recordCssAssetResult, getRecordedGeneratorCandidates, getSourceCandidates, getSourceCandidatesForEntries, waitForSourceCandidateSyncs, rememberMainCssSource, getRememberedMainCssSource } = context;
|
|
551
552
|
if (getResolvedConfig()?.command !== "build") return;
|
|
552
553
|
const isCssOutputAssetEntry = (entry) => {
|
|
553
554
|
const [, output] = entry;
|
|
@@ -569,11 +570,13 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
569
570
|
...cssHandlerOptions,
|
|
570
571
|
isMainChunk: false
|
|
571
572
|
};
|
|
572
|
-
const
|
|
573
|
+
const processed = isCssAssetProcessed(output, file);
|
|
574
|
+
const generatorRawSource = processed && cssHandlerOptions.isMainChunk ? getRememberedMainCssSource?.(file) ?? rawSource : rawSource;
|
|
575
|
+
const generated = shouldGenerateCssByGenerator(opts, file, generatorRawSource, processed) ? await require_incremental_runtime_class_set.generateCssByGenerator({
|
|
573
576
|
opts,
|
|
574
577
|
runtimeState,
|
|
575
578
|
runtime: generatorRuntime,
|
|
576
|
-
rawSource,
|
|
579
|
+
rawSource: generatorRawSource,
|
|
577
580
|
file,
|
|
578
581
|
cssHandlerOptions,
|
|
579
582
|
cssUserHandlerOptions,
|
|
@@ -586,7 +589,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
586
589
|
registerGeneratorDependencies$1(this, generated.dependencies);
|
|
587
590
|
debug("css finalizer generated result: %s bytes=%d", file, nextCss.length);
|
|
588
591
|
recordCssAssetResult?.(file, nextCss);
|
|
589
|
-
if (cssHandlerOptions.isMainChunk) rememberMainCssSource?.(file,
|
|
592
|
+
if (cssHandlerOptions.isMainChunk) rememberMainCssSource?.(file, generatorRawSource);
|
|
590
593
|
}
|
|
591
594
|
output.source = nextCss;
|
|
592
595
|
markCssAssetProcessed(output, file);
|
|
@@ -908,6 +911,7 @@ function createGenerateBundleHook(context) {
|
|
|
908
911
|
const { opts, runtimeState, ensureBundleRuntimeClassSet, debug, getResolvedConfig, markCssAssetProcessed, recordCssAssetResult, getSourceCandidates, getSourceCandidatesForEntries, waitForSourceCandidateSyncs, rememberMainCssSource, getRememberedMainCssSources, getRememberedMainCssSignature, setRememberedMainCssSignature, recordGeneratorCandidates, hmrTimingRecorder } = context;
|
|
909
912
|
const { cache, onEnd, onStart, onUpdate, styleHandler, templateHandler, jsHandler, uniAppX } = opts;
|
|
910
913
|
const generatorOptions = require_generator.normalizeWeappTailwindcssGeneratorOptions(opts.generator);
|
|
914
|
+
const isWebGeneratorTarget = generatorOptions.target === "web";
|
|
911
915
|
const { getCssHandlerOptions, getCssUserHandlerOptions } = cssHandlerOptions;
|
|
912
916
|
await runtimeState.readyPromise;
|
|
913
917
|
debug("start");
|
|
@@ -1059,6 +1063,13 @@ function createGenerateBundleHook(context) {
|
|
|
1059
1063
|
if (type === "css" && originalSource.type === "asset") {
|
|
1060
1064
|
metrics.css.total++;
|
|
1061
1065
|
const rawSource = originalEntrySource;
|
|
1066
|
+
if (isWebGeneratorTarget) {
|
|
1067
|
+
originalSource.source = rawSource;
|
|
1068
|
+
markCssAssetProcessed?.(originalSource, file);
|
|
1069
|
+
onUpdate(file, rawSource, rawSource);
|
|
1070
|
+
debug("css skip web target: %s", file);
|
|
1071
|
+
continue;
|
|
1072
|
+
}
|
|
1062
1073
|
const cssRuntimeAffectingSignature = snapshot.runtimeAffectingSignatureByFile.get(file) ?? rawSource;
|
|
1063
1074
|
const cssShareScope = createCssTransformShareScopeKey(opts, file, rawSource);
|
|
1064
1075
|
const cssHandlerOptions = getCssHandlerOptions(file);
|
|
@@ -1721,6 +1732,7 @@ function WeappTailwindcss(options = {}) {
|
|
|
1721
1732
|
const tailwindcssMajorVersion = initialTwPatcher.majorVersion ?? 0;
|
|
1722
1733
|
const shouldOwnTailwindGeneration = !disabledOptions.plugin;
|
|
1723
1734
|
const shouldRewriteCssImports = tailwindcssMajorVersion >= 4;
|
|
1735
|
+
const shouldInferAppType = !hasExplicitAppType && opts.generator?.target !== "web";
|
|
1724
1736
|
const hasInitialTailwindCssRoots = require_tailwindcss.hasConfiguredTailwindV4CssRoots({
|
|
1725
1737
|
...options,
|
|
1726
1738
|
cssEntries: opts.cssEntries ?? options.cssEntries
|
|
@@ -1966,6 +1978,7 @@ function WeappTailwindcss(options = {}) {
|
|
|
1966
1978
|
if (cssRuntimeSignature) rememberedMainCssSignatureByFile.set(file, cssRuntimeSignature);
|
|
1967
1979
|
};
|
|
1968
1980
|
const getRememberedMainCssSources = () => rememberedMainCssSources;
|
|
1981
|
+
const getRememberedMainCssSource = (file) => rememberedMainCssSources.get(file);
|
|
1969
1982
|
const getRememberedMainCssSignature = (file) => rememberedMainCssSignatureByFile.get(file);
|
|
1970
1983
|
const setRememberedMainCssSignature = (file, cssRuntimeSignature) => {
|
|
1971
1984
|
rememberedMainCssSignatureByFile.set(file, cssRuntimeSignature);
|
|
@@ -2000,9 +2013,14 @@ function WeappTailwindcss(options = {}) {
|
|
|
2000
2013
|
getSourceCandidates,
|
|
2001
2014
|
getSourceCandidatesForEntries,
|
|
2002
2015
|
waitForSourceCandidateSyncs,
|
|
2003
|
-
rememberMainCssSource
|
|
2016
|
+
rememberMainCssSource,
|
|
2017
|
+
getRememberedMainCssSource
|
|
2004
2018
|
});
|
|
2005
2019
|
const isIosPlatform = require_utils.resolveUniUtsPlatform().isAppIos;
|
|
2020
|
+
const prepareTailwindGeneration = async () => {
|
|
2021
|
+
if (shouldDiscoverAutoCssSources()) await discoverAndRegisterAutoCssSources();
|
|
2022
|
+
await syncSourceCandidateScan();
|
|
2023
|
+
};
|
|
2006
2024
|
const uniAppXPlugins = uniAppXEnabled ? createUniAppXPlugins({
|
|
2007
2025
|
appType: opts.appType ?? "uni-app-x",
|
|
2008
2026
|
customAttributesEntities,
|
|
@@ -2056,8 +2074,7 @@ function WeappTailwindcss(options = {}) {
|
|
|
2056
2074
|
},
|
|
2057
2075
|
async buildStart() {
|
|
2058
2076
|
await hmrTimingRecorder.measure("sourceCandidates.buildStart", async () => {
|
|
2059
|
-
|
|
2060
|
-
await syncSourceCandidateScan();
|
|
2077
|
+
await prepareTailwindGeneration();
|
|
2061
2078
|
}, { emit: false });
|
|
2062
2079
|
}
|
|
2063
2080
|
},
|
|
@@ -2106,7 +2123,7 @@ function WeappTailwindcss(options = {}) {
|
|
|
2106
2123
|
shouldRefreshRuntime = true;
|
|
2107
2124
|
}
|
|
2108
2125
|
}
|
|
2109
|
-
if (
|
|
2126
|
+
if (shouldInferAppType && resolvedRoot) {
|
|
2110
2127
|
const nextAppType = resolveImplicitAppTypeFromViteRoot(resolvedRoot);
|
|
2111
2128
|
if (nextAppType && opts.appType !== nextAppType) {
|
|
2112
2129
|
const previousAppType = opts.appType;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { B as omitUndefined, D as filterUnsupportedMiniProgramTailwindV4Candidates, F as createDebug, R as findTailwindConfig, V as findNearestPackageRoot, _ as resolveViteSourceScanEntries, g as resolveTailwindV4EntriesFromCssCached, l as getRuntimeClassSetSignature, m as discoverTailwindV4CssEntries, p as createViteSourceScanMatcher, v as resolveViteTailwindV4CssDependencies, z as resolveTailwindcssOptions } from "./v3-engine-
|
|
2
|
-
import { i as normalizeWeappTailwindcssGeneratorOptions } from "./generator-
|
|
3
|
-
import { a as validateCandidatesByGenerator, c as hasTailwindSourceDirectives, i as generateCssByGenerator, l as normalizeTailwindSourceForGenerator, n as createHmrTimingRecorder, o as processCachedTask, s as hasTailwindRootDirectives, t as createBundleRuntimeClassSetManager, u as hasTailwindGeneratedCssMarkers } from "./incremental-runtime-class-set-
|
|
4
|
-
import { a as analyzeSource, c as isClassContextLiteralPath, g as createTailwindRuntimeReadyPromise, h as collectRuntimeClassSet, i as createAttributeMatcher, l as replaceWxml, m as toCustomAttributesEntities, n as getCompilerContext, o as JsTokenUpdater, p as vitePluginName, r as generateCode, s as _defineProperty, t as shouldSkipJsTransform, u as babelParse, v as refreshTailwindRuntimeState } from "./precheck-
|
|
1
|
+
import { B as omitUndefined, D as filterUnsupportedMiniProgramTailwindV4Candidates, F as createDebug, R as findTailwindConfig, V as findNearestPackageRoot, _ as resolveViteSourceScanEntries, g as resolveTailwindV4EntriesFromCssCached, l as getRuntimeClassSetSignature, m as discoverTailwindV4CssEntries, p as createViteSourceScanMatcher, v as resolveViteTailwindV4CssDependencies, z as resolveTailwindcssOptions } from "./v3-engine-CCxDqZ8e.mjs";
|
|
2
|
+
import { i as normalizeWeappTailwindcssGeneratorOptions } from "./generator-Ber8UVgv.mjs";
|
|
3
|
+
import { a as validateCandidatesByGenerator, c as hasTailwindSourceDirectives, i as generateCssByGenerator, l as normalizeTailwindSourceForGenerator, n as createHmrTimingRecorder, o as processCachedTask, s as hasTailwindRootDirectives, t as createBundleRuntimeClassSetManager, u as hasTailwindGeneratedCssMarkers } from "./incremental-runtime-class-set-DC0RsBbK.mjs";
|
|
4
|
+
import { a as analyzeSource, c as isClassContextLiteralPath, g as createTailwindRuntimeReadyPromise, h as collectRuntimeClassSet, i as createAttributeMatcher, l as replaceWxml, m as toCustomAttributesEntities, n as getCompilerContext, o as JsTokenUpdater, p as vitePluginName, r as generateCode, s as _defineProperty, t as shouldSkipJsTransform, u as babelParse, v as refreshTailwindRuntimeState } from "./precheck-CX-5VqM1.mjs";
|
|
5
5
|
import { o as resolveUniUtsPlatform } from "./utils-CGBVVNm6.mjs";
|
|
6
|
-
import { c as upsertTailwindV4CssSource, i as resolveUniAppXOptions, r as isUniAppXEnabled, s as hasConfiguredTailwindV4CssRoots } from "./tailwindcss-
|
|
7
|
-
import { n as isSourceCandidateRequest, t as createSourceCandidateCollector } from "./source-candidates-
|
|
8
|
-
import { a as createBundleModuleGraphOptions, c as resolvePluginDisabledState, d as normalizeOutputPathKey, i as applyLinkedResults, l as isSourceStyleRequest, n as createBundleBuildState, o as pushConcurrentTaskFactories, p as toAbsoluteOutputPath, r as updateBundleBuildState, s as resolvePackageDir, t as buildBundleSnapshot } from "./bundle-state-
|
|
6
|
+
import { c as upsertTailwindV4CssSource, i as resolveUniAppXOptions, r as isUniAppXEnabled, s as hasConfiguredTailwindV4CssRoots } from "./tailwindcss-D74Wk4ys.mjs";
|
|
7
|
+
import { n as isSourceCandidateRequest, t as createSourceCandidateCollector } from "./source-candidates-DGlDzkvf.mjs";
|
|
8
|
+
import { a as createBundleModuleGraphOptions, c as resolvePluginDisabledState, d as normalizeOutputPathKey, i as applyLinkedResults, l as isSourceStyleRequest, n as createBundleBuildState, o as pushConcurrentTaskFactories, p as toAbsoluteOutputPath, r as updateBundleBuildState, s as resolvePackageDir, t as buildBundleSnapshot } from "./bundle-state-YW-zLcsc.mjs";
|
|
9
9
|
import { t as logger$1 } from "./logger-CZUxvJJD.mjs";
|
|
10
10
|
import fs, { existsSync, readFileSync } from "node:fs";
|
|
11
11
|
import path from "node:path";
|
|
@@ -527,6 +527,7 @@ function createCssHandlerOptions(opts, majorVersion, file) {
|
|
|
527
527
|
}
|
|
528
528
|
function shouldGenerateCssByGenerator(opts, file, rawSource, processed) {
|
|
529
529
|
const generatorOptions = normalizeWeappTailwindcssGeneratorOptions(opts.generator);
|
|
530
|
+
if (generatorOptions.target === "web") return false;
|
|
530
531
|
if (hasTailwindGeneratedCssMarkers(rawSource) || hasTailwindSourceDirectives(rawSource, { importFallback: generatorOptions.importFallback })) return true;
|
|
531
532
|
if (opts.twPatcher.majorVersion === 3) return false;
|
|
532
533
|
return processed && shouldFinalizeProcessedCssAsset(opts, file);
|
|
@@ -540,7 +541,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
540
541
|
generateBundle: {
|
|
541
542
|
order: "post",
|
|
542
543
|
async handler(_options, bundle) {
|
|
543
|
-
const { opts, runtimeState, ensureRuntimeClassSet, isCssAssetProcessed, markCssAssetProcessed, debug, getResolvedConfig, recordCssAssetResult, getRecordedGeneratorCandidates, getSourceCandidates, getSourceCandidatesForEntries, waitForSourceCandidateSyncs, rememberMainCssSource } = context;
|
|
544
|
+
const { opts, runtimeState, ensureRuntimeClassSet, isCssAssetProcessed, markCssAssetProcessed, debug, getResolvedConfig, recordCssAssetResult, getRecordedGeneratorCandidates, getSourceCandidates, getSourceCandidatesForEntries, waitForSourceCandidateSyncs, rememberMainCssSource, getRememberedMainCssSource } = context;
|
|
544
545
|
if (getResolvedConfig()?.command !== "build") return;
|
|
545
546
|
const isCssOutputAssetEntry = (entry) => {
|
|
546
547
|
const [, output] = entry;
|
|
@@ -562,11 +563,13 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
562
563
|
...cssHandlerOptions,
|
|
563
564
|
isMainChunk: false
|
|
564
565
|
};
|
|
565
|
-
const
|
|
566
|
+
const processed = isCssAssetProcessed(output, file);
|
|
567
|
+
const generatorRawSource = processed && cssHandlerOptions.isMainChunk ? getRememberedMainCssSource?.(file) ?? rawSource : rawSource;
|
|
568
|
+
const generated = shouldGenerateCssByGenerator(opts, file, generatorRawSource, processed) ? await generateCssByGenerator({
|
|
566
569
|
opts,
|
|
567
570
|
runtimeState,
|
|
568
571
|
runtime: generatorRuntime,
|
|
569
|
-
rawSource,
|
|
572
|
+
rawSource: generatorRawSource,
|
|
570
573
|
file,
|
|
571
574
|
cssHandlerOptions,
|
|
572
575
|
cssUserHandlerOptions,
|
|
@@ -579,7 +582,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
579
582
|
registerGeneratorDependencies$1(this, generated.dependencies);
|
|
580
583
|
debug("css finalizer generated result: %s bytes=%d", file, nextCss.length);
|
|
581
584
|
recordCssAssetResult?.(file, nextCss);
|
|
582
|
-
if (cssHandlerOptions.isMainChunk) rememberMainCssSource?.(file,
|
|
585
|
+
if (cssHandlerOptions.isMainChunk) rememberMainCssSource?.(file, generatorRawSource);
|
|
583
586
|
}
|
|
584
587
|
output.source = nextCss;
|
|
585
588
|
markCssAssetProcessed(output, file);
|
|
@@ -901,6 +904,7 @@ function createGenerateBundleHook(context) {
|
|
|
901
904
|
const { opts, runtimeState, ensureBundleRuntimeClassSet, debug, getResolvedConfig, markCssAssetProcessed, recordCssAssetResult, getSourceCandidates, getSourceCandidatesForEntries, waitForSourceCandidateSyncs, rememberMainCssSource, getRememberedMainCssSources, getRememberedMainCssSignature, setRememberedMainCssSignature, recordGeneratorCandidates, hmrTimingRecorder } = context;
|
|
902
905
|
const { cache, onEnd, onStart, onUpdate, styleHandler, templateHandler, jsHandler, uniAppX } = opts;
|
|
903
906
|
const generatorOptions = normalizeWeappTailwindcssGeneratorOptions(opts.generator);
|
|
907
|
+
const isWebGeneratorTarget = generatorOptions.target === "web";
|
|
904
908
|
const { getCssHandlerOptions, getCssUserHandlerOptions } = cssHandlerOptions;
|
|
905
909
|
await runtimeState.readyPromise;
|
|
906
910
|
debug("start");
|
|
@@ -1052,6 +1056,13 @@ function createGenerateBundleHook(context) {
|
|
|
1052
1056
|
if (type === "css" && originalSource.type === "asset") {
|
|
1053
1057
|
metrics.css.total++;
|
|
1054
1058
|
const rawSource = originalEntrySource;
|
|
1059
|
+
if (isWebGeneratorTarget) {
|
|
1060
|
+
originalSource.source = rawSource;
|
|
1061
|
+
markCssAssetProcessed?.(originalSource, file);
|
|
1062
|
+
onUpdate(file, rawSource, rawSource);
|
|
1063
|
+
debug("css skip web target: %s", file);
|
|
1064
|
+
continue;
|
|
1065
|
+
}
|
|
1055
1066
|
const cssRuntimeAffectingSignature = snapshot.runtimeAffectingSignatureByFile.get(file) ?? rawSource;
|
|
1056
1067
|
const cssShareScope = createCssTransformShareScopeKey(opts, file, rawSource);
|
|
1057
1068
|
const cssHandlerOptions = getCssHandlerOptions(file);
|
|
@@ -1714,6 +1725,7 @@ function WeappTailwindcss(options = {}) {
|
|
|
1714
1725
|
const tailwindcssMajorVersion = initialTwPatcher.majorVersion ?? 0;
|
|
1715
1726
|
const shouldOwnTailwindGeneration = !disabledOptions.plugin;
|
|
1716
1727
|
const shouldRewriteCssImports = tailwindcssMajorVersion >= 4;
|
|
1728
|
+
const shouldInferAppType = !hasExplicitAppType && opts.generator?.target !== "web";
|
|
1717
1729
|
const hasInitialTailwindCssRoots = hasConfiguredTailwindV4CssRoots({
|
|
1718
1730
|
...options,
|
|
1719
1731
|
cssEntries: opts.cssEntries ?? options.cssEntries
|
|
@@ -1959,6 +1971,7 @@ function WeappTailwindcss(options = {}) {
|
|
|
1959
1971
|
if (cssRuntimeSignature) rememberedMainCssSignatureByFile.set(file, cssRuntimeSignature);
|
|
1960
1972
|
};
|
|
1961
1973
|
const getRememberedMainCssSources = () => rememberedMainCssSources;
|
|
1974
|
+
const getRememberedMainCssSource = (file) => rememberedMainCssSources.get(file);
|
|
1962
1975
|
const getRememberedMainCssSignature = (file) => rememberedMainCssSignatureByFile.get(file);
|
|
1963
1976
|
const setRememberedMainCssSignature = (file, cssRuntimeSignature) => {
|
|
1964
1977
|
rememberedMainCssSignatureByFile.set(file, cssRuntimeSignature);
|
|
@@ -1993,9 +2006,14 @@ function WeappTailwindcss(options = {}) {
|
|
|
1993
2006
|
getSourceCandidates,
|
|
1994
2007
|
getSourceCandidatesForEntries,
|
|
1995
2008
|
waitForSourceCandidateSyncs,
|
|
1996
|
-
rememberMainCssSource
|
|
2009
|
+
rememberMainCssSource,
|
|
2010
|
+
getRememberedMainCssSource
|
|
1997
2011
|
});
|
|
1998
2012
|
const isIosPlatform = resolveUniUtsPlatform().isAppIos;
|
|
2013
|
+
const prepareTailwindGeneration = async () => {
|
|
2014
|
+
if (shouldDiscoverAutoCssSources()) await discoverAndRegisterAutoCssSources();
|
|
2015
|
+
await syncSourceCandidateScan();
|
|
2016
|
+
};
|
|
1999
2017
|
const uniAppXPlugins = uniAppXEnabled ? createUniAppXPlugins({
|
|
2000
2018
|
appType: opts.appType ?? "uni-app-x",
|
|
2001
2019
|
customAttributesEntities,
|
|
@@ -2049,8 +2067,7 @@ function WeappTailwindcss(options = {}) {
|
|
|
2049
2067
|
},
|
|
2050
2068
|
async buildStart() {
|
|
2051
2069
|
await hmrTimingRecorder.measure("sourceCandidates.buildStart", async () => {
|
|
2052
|
-
|
|
2053
|
-
await syncSourceCandidateScan();
|
|
2070
|
+
await prepareTailwindGeneration();
|
|
2054
2071
|
}, { emit: false });
|
|
2055
2072
|
}
|
|
2056
2073
|
},
|
|
@@ -2099,7 +2116,7 @@ function WeappTailwindcss(options = {}) {
|
|
|
2099
2116
|
shouldRefreshRuntime = true;
|
|
2100
2117
|
}
|
|
2101
2118
|
}
|
|
2102
|
-
if (
|
|
2119
|
+
if (shouldInferAppType && resolvedRoot) {
|
|
2103
2120
|
const nextAppType = resolveImplicitAppTypeFromViteRoot(resolvedRoot);
|
|
2104
2121
|
if (nextAppType && opts.appType !== nextAppType) {
|
|
2105
2122
|
const previousAppType = opts.appType;
|
package/dist/vite.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_vite = require("./vite-
|
|
2
|
+
const require_vite = require("./vite-DnHdmHHD.js");
|
|
3
3
|
exports.WeappTailwindcss = require_vite.WeappTailwindcss;
|
|
4
4
|
exports.weappTailwindcss = require_vite.WeappTailwindcss;
|
package/dist/vite.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as WeappTailwindcss } from "./vite-
|
|
1
|
+
import { t as WeappTailwindcss } from "./vite-bmU2kkO6.mjs";
|
|
2
2
|
export { WeappTailwindcss, WeappTailwindcss as weappTailwindcss };
|