weapp-tailwindcss 5.0.0-next.3 → 5.0.0-next.7
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/README.md +4 -5
- package/bin/weapp-tailwindcss.js +1 -21
- package/dist/bundlers/shared/css-cleanup/at-rules.d.ts +2 -0
- package/dist/bundlers/shared/css-cleanup/color-gamut.d.ts +3 -0
- package/dist/bundlers/shared/css-cleanup/root-cleanups.d.ts +4 -0
- package/dist/bundlers/shared/css-cleanup/selectors.d.ts +8 -0
- package/dist/bundlers/shared/css-cleanup.d.ts +1 -2
- package/dist/bundlers/shared/generator-css/config-directive.d.ts +2 -0
- package/dist/bundlers/shared/generator-css/directives.d.ts +11 -0
- package/dist/bundlers/shared/generator-css/legacy-compat.d.ts +7 -0
- package/dist/bundlers/shared/generator-css/legacy-selectors.d.ts +5 -0
- package/dist/bundlers/shared/generator-css/legacy-units.d.ts +1 -0
- package/dist/bundlers/shared/generator-css/markers.d.ts +16 -0
- package/dist/bundlers/shared/generator-css/source-files.d.ts +11 -0
- package/dist/bundlers/shared/generator-css/source-resolver.d.ts +10 -0
- package/dist/bundlers/shared/generator-css.d.ts +12 -22
- package/dist/bundlers/vite/css-finalizer.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle/candidates.d.ts +2 -0
- package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +20 -0
- package/dist/bundlers/vite/generate-bundle/css-share-scope.d.ts +3 -0
- package/dist/bundlers/vite/generate-bundle/dirty-state.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/js-entries.d.ts +2 -0
- package/dist/bundlers/vite/generate-bundle/js-handler-options.d.ts +8 -0
- package/dist/bundlers/vite/generate-bundle/js-linking.d.ts +13 -0
- package/dist/bundlers/vite/generate-bundle/metrics.d.ts +17 -0
- package/dist/bundlers/vite/generate-bundle/process-plan.d.ts +9 -0
- package/dist/bundlers/vite/generate-bundle/rollup-assets.d.ts +7 -0
- package/dist/bundlers/vite/generate-bundle/signatures.d.ts +8 -0
- package/dist/bundlers/vite/generate-bundle.d.ts +2 -1
- package/dist/bundlers/vite/index.d.ts +1 -1
- package/dist/bundlers/vite/official-tailwind-plugins.d.ts +5 -0
- package/dist/bundlers/vite/postcss-config.d.ts +6 -0
- package/dist/bundlers/vite/rewrite-css-imports.d.ts +1 -0
- package/dist/bundlers/vite/runtime-class-set.d.ts +22 -0
- package/dist/bundlers/vite/tailwind-basedir.d.ts +1 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +1 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +1 -1
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +0 -1
- package/dist/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.d.ts +1 -1
- package/dist/cache-DPN5yKSX.js +497 -0
- package/dist/cache-nq0_XJoS.mjs +429 -0
- package/dist/cli/context.d.ts +0 -3
- package/dist/cli/helpers.d.ts +1 -2
- package/dist/cli/mount-options.d.ts +2 -0
- package/dist/cli/types.d.ts +0 -2
- package/dist/cli.js +108 -598
- package/dist/cli.mjs +119 -608
- package/dist/constants.d.ts +1 -2
- package/dist/context/tailwindcss.d.ts +1 -1
- package/dist/core.js +13 -20
- package/dist/core.mjs +8 -14
- package/dist/css-macro/postcss.js +1 -1
- package/dist/css-macro/postcss.mjs +1 -1
- package/dist/css-macro.d.ts +1 -0
- package/dist/css-macro.js +2 -2
- package/dist/css-macro.mjs +2 -2
- package/dist/defaults.d.ts +15 -1
- package/dist/defaults.js +33 -14
- package/dist/defaults.mjs +30 -15
- package/dist/generator/index.d.ts +1 -1
- package/dist/generator/options.d.ts +3 -4
- package/dist/{generator-Y-Ikv4Fu.mjs → generator-CzfdCZyd.mjs} +277 -23
- package/dist/{generator-mmhXzZnv.js → generator-TOp4uz7c.js} +281 -27
- package/dist/{generator-css-Bwy_Uz89.mjs → generator-css-B938WI9a.mjs} +694 -506
- package/dist/{generator-css-CRLrHW4F.js → generator-css-Dnpl-IY2.js} +699 -505
- package/dist/generator.js +1 -1
- package/dist/generator.mjs +1 -1
- package/dist/gulp.js +29 -28
- package/dist/gulp.mjs +25 -24
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -6
- package/dist/index.mjs +5 -5
- package/dist/js/index.d.ts +1 -0
- package/dist/js/literal-transform.d.ts +2 -0
- package/dist/logger-BRy6XPQ2.js +1 -0
- package/dist/logger-Bub1jggA.mjs +2 -0
- package/dist/postcss/config-directive.d.ts +1 -0
- package/dist/postcss/context.d.ts +9 -0
- package/dist/postcss/source-files.d.ts +8 -0
- package/dist/postcss/tailwind-version.d.ts +3 -0
- package/dist/postcss-BtAP6sQO.mjs +288 -0
- package/dist/postcss-WsXlC7A-.js +298 -0
- package/dist/postcss.d.ts +2 -2
- package/dist/postcss.js +3 -276
- package/dist/postcss.mjs +1 -269
- package/dist/{recorder-GdTJ3QqX.js → precheck-Dka94ArV.js} +141 -283
- package/dist/{recorder-XdFvVASS.mjs → precheck-DlrmwCc-.mjs} +106 -247
- package/dist/presets.js +6 -4
- package/dist/presets.mjs +4 -2
- package/dist/reset.d.ts +1 -0
- package/dist/{css-imports-BbrbluP9.js → run-tasks-B50A3pxt.js} +6 -55
- package/dist/{css-imports-CSdPq_Sc.mjs → run-tasks-DdNi-hkk.mjs} +5 -42
- package/dist/runtime-patch-pGdCqAEu.mjs +71 -0
- package/dist/runtime-patch-qwuisukL.js +85 -0
- package/dist/tailwindcss/miniprogram.d.ts +5 -1
- package/dist/tailwindcss/patcher-options.d.ts +3 -51
- package/dist/tailwindcss/patcher.d.ts +1 -2
- package/dist/tailwindcss/runtime-patch.d.ts +5 -0
- package/dist/tailwindcss/runtime.d.ts +2 -3
- package/dist/tailwindcss/targets.d.ts +1 -5
- package/dist/tailwindcss/v4/patcher-options.d.ts +1 -23
- package/dist/tailwindcss/v4/patcher.d.ts +2 -1
- package/dist/tailwindcss/v4-engine/types.d.ts +1 -1
- package/dist/tailwindcss/version.d.ts +4 -0
- package/dist/{logger-BoVx1Dbt.mjs → tailwindcss-BIJ185GB.mjs} +25 -434
- package/dist/{logger-BZ45DZJT.js → tailwindcss-T1U5T-iF.js} +30 -468
- package/dist/typedoc.export.d.ts +0 -2
- package/dist/types/index.d.ts +2 -9
- package/dist/types/shared.d.ts +3 -0
- package/dist/types/user-defined-options/general.d.ts +0 -2
- package/dist/types/user-defined-options/important.d.ts +3 -3
- package/dist/uni-app-x/vite.d.ts +1 -1
- package/dist/utils/disabled.d.ts +2 -3
- package/dist/{vite-BDywuCjn.mjs → vite-BXChkciE.mjs} +669 -481
- package/dist/{vite-DgRh_GXn.js → vite-D0CoRblu.js} +707 -519
- package/dist/vite.d.ts +1 -2
- package/dist/vite.js +3 -4
- package/dist/vite.mjs +2 -2
- package/dist/weapp-tw-css-import-rewrite-loader.js +1 -1
- package/dist/{webpack-CiHqVZTg.mjs → webpack-BNdGm9KL.mjs} +224 -38
- package/dist/{webpack-CAJR4hhP.js → webpack-D-sUCY0u.js} +250 -69
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +23 -35
- package/dist/bundlers/shared/generator-candidates.d.ts +0 -5
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-assets.d.ts +0 -14
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-loaders.d.ts +0 -15
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v4.d.ts +0 -9
- package/dist/bundlers/webpack/shared/css-imports.d.ts +0 -6
- package/dist/cli/config.d.ts +0 -5
- package/dist/cli/helpers/patch-cwd.d.ts +0 -1
- package/dist/cli/mount-options/patch-status.d.ts +0 -2
- package/dist/cli/patch-options.d.ts +0 -6
- package/dist/cli/tokens.d.ts +0 -4
- package/dist/cli/workspace/package-dirs.d.ts +0 -3
- package/dist/cli/workspace/patch-package.d.ts +0 -3
- package/dist/cli/workspace/patch-utils.d.ts +0 -3
- package/dist/cli/workspace/types.d.ts +0 -11
- package/dist/cli/workspace/workspace-globs.d.ts +0 -2
- package/dist/cli/workspace/workspace-io.d.ts +0 -1
- package/dist/cli/workspace/workspace-lock.d.ts +0 -1
- package/dist/cli/workspace.d.ts +0 -2
- package/dist/experimental/index.d.ts +0 -2
- package/dist/experimental/oxc/ast-utils.d.ts +0 -30
- package/dist/experimental/oxc/index.d.ts +0 -2
- package/dist/experimental/oxc/module-specifiers.d.ts +0 -2
- package/dist/experimental/shared/cache.d.ts +0 -3
- package/dist/experimental/shared/transform.d.ts +0 -3
- package/dist/experimental/shared.d.ts +0 -8
- package/dist/experimental/swc/ast-utils.d.ts +0 -30
- package/dist/experimental/swc/index.d.ts +0 -2
- package/dist/experimental/swc/module-specifiers.d.ts +0 -2
- package/dist/js/syntax.d.ts +0 -10
- package/dist/loader-anchors-1MumTAtA.mjs +0 -205
- package/dist/loader-anchors-TrFvT6g1.js +0 -273
- package/dist/patcher-options-6gJN2EXy.js +0 -115
- package/dist/patcher-options-DQfR5xxT.mjs +0 -92
- package/dist/tailwindcss/recorder.d.ts +0 -13
- package/dist/tailwindcss/targets/paths.d.ts +0 -13
- package/dist/tailwindcss/targets/record-io.d.ts +0 -5
- package/dist/tailwindcss/targets/recorder.d.ts +0 -3
- package/dist/tailwindcss/targets/types.d.ts +0 -35
- package/dist/types/disabled-options.d.ts +0 -4
- package/dist/webpack4.d.ts +0 -4
- package/dist/webpack4.js +0 -387
- package/dist/webpack4.mjs +0 -379
- package/scripts/postinstall.mjs +0 -59
- /package/dist/{constants-p1dyh1x1.js → constants-BoB_6lFw.js} +0 -0
- /package/dist/{constants-B-_T5UnW.mjs → constants-E_loJC49.mjs} +0 -0
- /package/dist/{utils-7DUGTFED.mjs → utils-BJjKRQgf.mjs} +0 -0
- /package/dist/{utils-DmC9_In3.js → utils-VZvGusYs.js} +0 -0
package/dist/postcss.mjs
CHANGED
|
@@ -1,270 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { createRequire } from "node:module";
|
|
3
|
-
import postcss from "postcss";
|
|
4
|
-
import path from "node:path";
|
|
5
|
-
import process from "node:process";
|
|
6
|
-
import { loadConfig } from "tailwindcss-config";
|
|
7
|
-
import { extractValidCandidates } from "tailwindcss-patch";
|
|
8
|
-
import { readFile, stat } from "node:fs/promises";
|
|
9
|
-
import fg from "fast-glob";
|
|
10
|
-
//#region src/postcss.ts
|
|
11
|
-
const PLUGIN_NAME = "weapp-tailwindcss";
|
|
12
|
-
const POSTCSS_SOURCE_EXTENSIONS = [
|
|
13
|
-
"html",
|
|
14
|
-
"wxml",
|
|
15
|
-
"axml",
|
|
16
|
-
"jxml",
|
|
17
|
-
"ksml",
|
|
18
|
-
"ttml",
|
|
19
|
-
"qml",
|
|
20
|
-
"tyml",
|
|
21
|
-
"xhsml",
|
|
22
|
-
"swan",
|
|
23
|
-
"vue",
|
|
24
|
-
"mpx",
|
|
25
|
-
"js",
|
|
26
|
-
"jsx",
|
|
27
|
-
"ts",
|
|
28
|
-
"tsx"
|
|
29
|
-
];
|
|
30
|
-
function resolveInputFile(result) {
|
|
31
|
-
const from = result.opts.from;
|
|
32
|
-
return typeof from === "string" && from.length > 0 ? from : void 0;
|
|
33
|
-
}
|
|
34
|
-
function resolvePostcssBase(result, options) {
|
|
35
|
-
if (options.base) return options.base;
|
|
36
|
-
const inputFile = resolveInputFile(result);
|
|
37
|
-
return inputFile ? path.dirname(inputFile) : process.cwd();
|
|
38
|
-
}
|
|
39
|
-
function resolvePostcssProjectRoot(result, options) {
|
|
40
|
-
if (options.projectRoot) return options.projectRoot;
|
|
41
|
-
const inputFile = resolveInputFile(result);
|
|
42
|
-
return inputFile ? path.dirname(inputFile) : process.cwd();
|
|
43
|
-
}
|
|
44
|
-
function replaceRootCss(root, css, result) {
|
|
45
|
-
const nextRoot = postcss.parse(css, { from: resolveInputFile(result) });
|
|
46
|
-
root.removeAll();
|
|
47
|
-
root.append(nextRoot.nodes);
|
|
48
|
-
}
|
|
49
|
-
function addDependencyMessages(result, generated) {
|
|
50
|
-
for (const file of generated.dependencies) result.messages.push({
|
|
51
|
-
type: "dependency",
|
|
52
|
-
plugin: PLUGIN_NAME,
|
|
53
|
-
file
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
function parseLocalSourceParam(params) {
|
|
57
|
-
const value = params.trim();
|
|
58
|
-
if (!value || value === "none" || value.startsWith("not ") || value.startsWith("inline(")) return;
|
|
59
|
-
return /^(['"])(.+)\1$/.exec(value)?.[2];
|
|
60
|
-
}
|
|
61
|
-
function parseConfigParam(params) {
|
|
62
|
-
const value = params.trim();
|
|
63
|
-
return /^(['"])(.+)\1$/.exec(value)?.[2];
|
|
64
|
-
}
|
|
65
|
-
function parseSourceFileParam(params) {
|
|
66
|
-
const value = params.trim();
|
|
67
|
-
if (!value || value === "none" || value.startsWith("inline(")) return;
|
|
68
|
-
const negated = value.startsWith("not ");
|
|
69
|
-
const sourceValue = negated ? value.slice(4).trim() : value;
|
|
70
|
-
const match = /^(['"])(.+)\1$/.exec(sourceValue);
|
|
71
|
-
return match?.[2] ? {
|
|
72
|
-
negated,
|
|
73
|
-
sourcePath: match[2]
|
|
74
|
-
} : void 0;
|
|
75
|
-
}
|
|
76
|
-
function hasTailwindV4CssSyntax(root) {
|
|
77
|
-
let hasV4Syntax = false;
|
|
78
|
-
root.walkAtRules((rule) => {
|
|
79
|
-
if (rule.name === "theme" || rule.name === "source" || rule.name === "custom-variant") hasV4Syntax = true;
|
|
80
|
-
if (rule.name === "import" && /(['"])tailwindcss\1/.test(rule.params)) hasV4Syntax = true;
|
|
81
|
-
});
|
|
82
|
-
return hasV4Syntax;
|
|
83
|
-
}
|
|
84
|
-
function readPackageMajorVersion(packageName, base) {
|
|
85
|
-
try {
|
|
86
|
-
const pkg = createRequire(`${base}/package.json`)(`${packageName}/package.json`);
|
|
87
|
-
const major = Number(pkg.version?.split(".")[0]);
|
|
88
|
-
return major === 3 || major === 4 ? major : void 0;
|
|
89
|
-
} catch {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
function resolvePostcssTailwindVersion(root, result, options) {
|
|
94
|
-
if (options.version) return options.version;
|
|
95
|
-
if (hasTailwindV4CssSyntax(root)) return 4;
|
|
96
|
-
const packageName = options.packageName ?? "tailwindcss";
|
|
97
|
-
if (packageName === "@tailwindcss/postcss" || packageName.includes("tailwindcss4")) return 4;
|
|
98
|
-
if (packageName.includes("tailwindcss3")) return 3;
|
|
99
|
-
return readPackageMajorVersion(packageName, resolvePostcssProjectRoot(result, options)) ?? 4;
|
|
100
|
-
}
|
|
101
|
-
function getSourceExtension(file) {
|
|
102
|
-
return path.extname(file).slice(1) || void 0;
|
|
103
|
-
}
|
|
104
|
-
async function pathExistsAsDirectory(file) {
|
|
105
|
-
try {
|
|
106
|
-
return (await stat(file)).isDirectory();
|
|
107
|
-
} catch {
|
|
108
|
-
return false;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
async function expandLocalSourceFiles(sourcePath, base) {
|
|
112
|
-
const absoluteSource = path.isAbsolute(sourcePath) ? sourcePath : path.resolve(base, sourcePath);
|
|
113
|
-
if (await pathExistsAsDirectory(absoluteSource)) return fg(`**/*.{${POSTCSS_SOURCE_EXTENSIONS.join(",")}}`, {
|
|
114
|
-
absolute: true,
|
|
115
|
-
cwd: absoluteSource,
|
|
116
|
-
onlyFiles: true
|
|
117
|
-
});
|
|
118
|
-
return fg(sourcePath, {
|
|
119
|
-
absolute: true,
|
|
120
|
-
cwd: base,
|
|
121
|
-
onlyFiles: true
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
async function resolveTailwindSourceEntry(sourcePath, base, negated) {
|
|
125
|
-
const absoluteSource = path.isAbsolute(sourcePath) ? path.resolve(sourcePath) : path.resolve(base, sourcePath);
|
|
126
|
-
if (await pathExistsAsDirectory(absoluteSource)) return {
|
|
127
|
-
base: absoluteSource,
|
|
128
|
-
negated,
|
|
129
|
-
pattern: "**/*"
|
|
130
|
-
};
|
|
131
|
-
if (path.isAbsolute(sourcePath)) return {
|
|
132
|
-
base: path.dirname(absoluteSource),
|
|
133
|
-
negated,
|
|
134
|
-
pattern: path.basename(absoluteSource)
|
|
135
|
-
};
|
|
136
|
-
return {
|
|
137
|
-
base,
|
|
138
|
-
negated,
|
|
139
|
-
pattern: sourcePath
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
function collectConfigPaths(root, base) {
|
|
143
|
-
const configPaths = [];
|
|
144
|
-
root.walkAtRules("config", (rule) => {
|
|
145
|
-
const configPath = parseConfigParam(rule.params);
|
|
146
|
-
if (configPath) configPaths.push(path.isAbsolute(configPath) ? configPath : path.resolve(base, configPath));
|
|
147
|
-
});
|
|
148
|
-
return [...new Set(configPaths)];
|
|
149
|
-
}
|
|
150
|
-
function normalizeContentFiles(content) {
|
|
151
|
-
if (typeof content === "string") return [content];
|
|
152
|
-
if (Array.isArray(content)) return content.flatMap((item) => normalizeContentFiles(item));
|
|
153
|
-
if (typeof content === "object" && content !== null && "files" in content) return normalizeContentFiles(content.files);
|
|
154
|
-
return [];
|
|
155
|
-
}
|
|
156
|
-
async function collectConfigContentFiles(root, base) {
|
|
157
|
-
const configPaths = collectConfigPaths(root, base);
|
|
158
|
-
const files = [];
|
|
159
|
-
for (const configPath of configPaths) {
|
|
160
|
-
const contentFiles = normalizeContentFiles((await loadConfig({
|
|
161
|
-
config: configPath,
|
|
162
|
-
cwd: path.dirname(configPath)
|
|
163
|
-
}))?.config.content);
|
|
164
|
-
for (const contentFile of contentFiles) files.push(...await expandLocalSourceFiles(contentFile, path.dirname(configPath)));
|
|
165
|
-
}
|
|
166
|
-
return {
|
|
167
|
-
configPaths,
|
|
168
|
-
files: [...new Set(files)]
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
async function collectAutoTailwindCandidates(root, result, options) {
|
|
172
|
-
const base = resolvePostcssBase(result, options);
|
|
173
|
-
const projectRoot = resolvePostcssProjectRoot(result, options);
|
|
174
|
-
const sourceEntryTasks = [];
|
|
175
|
-
if (!root.toString().includes("source(none)")) sourceEntryTasks.push(Promise.resolve({
|
|
176
|
-
base,
|
|
177
|
-
negated: false,
|
|
178
|
-
pattern: "**/*"
|
|
179
|
-
}));
|
|
180
|
-
root.walkAtRules("source", (rule) => {
|
|
181
|
-
const parsed = parseSourceFileParam(rule.params);
|
|
182
|
-
if (!parsed) return;
|
|
183
|
-
sourceEntryTasks.push(resolveTailwindSourceEntry(parsed.sourcePath, base, parsed.negated));
|
|
184
|
-
});
|
|
185
|
-
const sourceEntries = await Promise.all(sourceEntryTasks);
|
|
186
|
-
if (sourceEntries.length === 0) return /* @__PURE__ */ new Set();
|
|
187
|
-
const candidates = await extractValidCandidates({
|
|
188
|
-
base,
|
|
189
|
-
css: root.toString(),
|
|
190
|
-
cwd: projectRoot,
|
|
191
|
-
sources: sourceEntries
|
|
192
|
-
});
|
|
193
|
-
return new Set(candidates);
|
|
194
|
-
}
|
|
195
|
-
async function collectPostcssLocalSources(root, result, options) {
|
|
196
|
-
const base = resolvePostcssBase(result, options);
|
|
197
|
-
const sourcePaths = [];
|
|
198
|
-
root.walkAtRules("source", (rule) => {
|
|
199
|
-
const sourcePath = parseLocalSourceParam(rule.params);
|
|
200
|
-
if (sourcePath) sourcePaths.push(sourcePath);
|
|
201
|
-
});
|
|
202
|
-
const configContentFiles = await collectConfigContentFiles(root, base);
|
|
203
|
-
const files = [...new Set((await Promise.all(sourcePaths.map((sourcePath) => expandLocalSourceFiles(sourcePath, base)))).flat().concat(configContentFiles.files))];
|
|
204
|
-
const sources = await Promise.all(files.map(async (file) => ({
|
|
205
|
-
content: await readFile(file, "utf8"),
|
|
206
|
-
extension: getSourceExtension(file)
|
|
207
|
-
})));
|
|
208
|
-
return {
|
|
209
|
-
files: [...files, ...configContentFiles.configPaths],
|
|
210
|
-
sources
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
function addSourceDependencyMessages(result, files) {
|
|
214
|
-
for (const file of files) result.messages.push({
|
|
215
|
-
type: "dependency",
|
|
216
|
-
plugin: PLUGIN_NAME,
|
|
217
|
-
file
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
|
-
const weappTailwindcssPostcssPlugin = (options = {}) => {
|
|
221
|
-
return {
|
|
222
|
-
postcssPlugin: PLUGIN_NAME,
|
|
223
|
-
async Once(root, { result }) {
|
|
224
|
-
const { candidates, generator: userGeneratorOptions, sources, styleOptions, target: legacyTarget, ...sourceOptions } = options;
|
|
225
|
-
const generatorOptions = normalizeWeappTailwindcssGeneratorOptions(userGeneratorOptions);
|
|
226
|
-
if (generatorOptions.mode === "off") return;
|
|
227
|
-
const tailwindVersion = resolvePostcssTailwindVersion(root, result, options);
|
|
228
|
-
const [collectedSources, autoCandidates] = await Promise.all([collectPostcssLocalSources(root, result, options), collectAutoTailwindCandidates(root, result, options)]);
|
|
229
|
-
const generator = createWeappTailwindcssGenerator(tailwindVersion === 3 ? await resolveTailwindV3Source({
|
|
230
|
-
config: options.config,
|
|
231
|
-
css: sourceOptions.css ?? root.toString(),
|
|
232
|
-
base: resolvePostcssBase(result, options),
|
|
233
|
-
cwd: resolvePostcssProjectRoot(result, options),
|
|
234
|
-
projectRoot: resolvePostcssProjectRoot(result, options),
|
|
235
|
-
packageName: options.packageName,
|
|
236
|
-
postcssPlugin: options.postcssPlugin
|
|
237
|
-
}) : await resolveTailwindV4Source$1({
|
|
238
|
-
...sourceOptions,
|
|
239
|
-
css: sourceOptions.css ?? root.toString(),
|
|
240
|
-
base: resolvePostcssBase(result, options),
|
|
241
|
-
projectRoot: resolvePostcssProjectRoot(result, options)
|
|
242
|
-
}));
|
|
243
|
-
const generateOptions = {
|
|
244
|
-
candidates: new Set([...autoCandidates, ...candidates ?? []]),
|
|
245
|
-
scanSources: false,
|
|
246
|
-
sources: [...collectedSources.sources, ...sources ?? []],
|
|
247
|
-
styleOptions: {
|
|
248
|
-
...generatorOptions.styleOptions,
|
|
249
|
-
...styleOptions
|
|
250
|
-
},
|
|
251
|
-
tailwindcssV3Compatibility: generatorOptions.tailwindcssV3Compatibility,
|
|
252
|
-
target: legacyTarget ?? generatorOptions.target
|
|
253
|
-
};
|
|
254
|
-
const generated = await generator.generate(generateOptions);
|
|
255
|
-
replaceRootCss(root, generated.css, result);
|
|
256
|
-
addDependencyMessages(result, generated);
|
|
257
|
-
addSourceDependencyMessages(result, collectedSources.files);
|
|
258
|
-
result.messages.push({
|
|
259
|
-
type: "weapp-tailwindcss:generated",
|
|
260
|
-
plugin: PLUGIN_NAME,
|
|
261
|
-
target: generated.target,
|
|
262
|
-
classSet: generated.classSet,
|
|
263
|
-
rawCss: generated.rawCss
|
|
264
|
-
});
|
|
265
|
-
}
|
|
266
|
-
};
|
|
267
|
-
};
|
|
268
|
-
weappTailwindcssPostcssPlugin.postcss = true;
|
|
269
|
-
//#endregion
|
|
1
|
+
import { t as weappTailwindcssPostcssPlugin } from "./postcss-BtAP6sQO.mjs";
|
|
270
2
|
export { weappTailwindcssPostcssPlugin as default, weappTailwindcssPostcssPlugin };
|