weapp-tailwindcss 3.0.2 → 3.0.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/README.md +6 -2
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v4.d.ts +8 -0
- package/dist/cli.js +16 -7
- package/dist/cli.mjs +12 -7
- package/dist/constants.d.ts +1 -0
- package/dist/core.js +2 -2
- package/dist/core.mjs +2 -2
- package/dist/css-macro/index.js +1 -1
- package/dist/gulp.js +5 -66
- package/dist/gulp.mjs +4 -65
- package/dist/index-8OJKpYld.js +70 -0
- package/dist/{postcss-zkCNv4BC.js → index-Fkmyt0Rc.js} +55 -26
- package/dist/index-KpA8Y68V.js +142 -0
- package/dist/index-O8jpXUxP.mjs +140 -0
- package/dist/{postcss-irzTcRfl.mjs → index-_74RBzwy.mjs} +54 -26
- package/dist/{index-z25r_Htj.js → index-juOeq2Kt.js} +1 -1
- package/dist/index-u-U9HdG6.mjs +64 -0
- package/dist/index.js +9 -9
- package/dist/index.mjs +5 -5
- package/dist/{options-UXRHB24i.mjs → options-6YPFqoRJ.mjs} +2 -2
- package/dist/{options-5eiKwcXx.js → options-N9g3FpWO.js} +3 -3
- package/dist/postcss/plugins/ctx.d.ts +2 -0
- package/dist/postcss/selectorParser.d.ts +4 -1
- package/dist/postcss.js +7 -7
- package/dist/postcss.mjs +1 -1
- package/dist/replace.js +5 -5
- package/dist/v5-RkdOexPP.js +187 -0
- package/dist/v5-UTJ5AaEA.mjs +180 -0
- package/dist/vite.js +11 -142
- package/dist/vite.mjs +9 -144
- package/dist/weapp-tw-runtime-loader.js +1 -1
- package/dist/webpack.js +12 -186
- package/dist/webpack.mjs +11 -184
- package/dist/webpack4.d.ts +1 -0
- package/dist/webpack4.js +208 -0
- package/dist/webpack4.mjs +199 -0
- package/package.json +35 -26
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var options = require('./options-N9g3FpWO.js');
|
|
4
|
+
var index = require('./index-Fkmyt0Rc.js');
|
|
5
|
+
var defaults = require('./defaults-QOAV8NSV.js');
|
|
6
|
+
var index$1 = require('./index-juOeq2Kt.js');
|
|
7
|
+
|
|
8
|
+
const debug = index$1.createDebug('generateBundle: ');
|
|
9
|
+
function UnifiedViteWeappTailwindcssPlugin(options$1 = {}) {
|
|
10
|
+
if (options$1.customReplaceDictionary === undefined) {
|
|
11
|
+
options$1.customReplaceDictionary = 'simple';
|
|
12
|
+
}
|
|
13
|
+
const opts = options.getOptions(options$1);
|
|
14
|
+
const { disabled, onEnd, onLoad, onStart, onUpdate, templateHandler, styleHandler, patch, jsHandler, mainCssChunkMatcher, appType, setMangleRuntimeSet, cache, tailwindcssBasedir } = opts;
|
|
15
|
+
if (disabled) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
patch === null || patch === void 0 ? void 0 : patch();
|
|
19
|
+
const twPatcher = options.createTailwindcssPatcher();
|
|
20
|
+
onLoad();
|
|
21
|
+
return {
|
|
22
|
+
name: index.vitePluginName,
|
|
23
|
+
enforce: 'post',
|
|
24
|
+
generateBundle(opt, bundle) {
|
|
25
|
+
return options.__awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
debug('start');
|
|
27
|
+
onStart();
|
|
28
|
+
const entries = Object.entries(bundle);
|
|
29
|
+
const groupedEntries = defaults.getGroupedEntries(entries, opts);
|
|
30
|
+
const runtimeSet = twPatcher.getClassSet({
|
|
31
|
+
basedir: tailwindcssBasedir
|
|
32
|
+
});
|
|
33
|
+
setMangleRuntimeSet(runtimeSet);
|
|
34
|
+
debug('get runtimeSet, class count: %d', runtimeSet.size);
|
|
35
|
+
if (Array.isArray(groupedEntries.html)) {
|
|
36
|
+
let noCachedCount = 0;
|
|
37
|
+
for (let i = 0; i < groupedEntries.html.length; i++) {
|
|
38
|
+
const [file, originalSource] = groupedEntries.html[i];
|
|
39
|
+
const oldVal = originalSource.source.toString();
|
|
40
|
+
const hash = cache.computeHash(oldVal);
|
|
41
|
+
cache.calcHashValueChanged(file, hash);
|
|
42
|
+
yield cache.process(file, () => {
|
|
43
|
+
const source = cache.get(file);
|
|
44
|
+
if (source) {
|
|
45
|
+
originalSource.source = source;
|
|
46
|
+
debug('html cache hit: %s', file);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
}, () => {
|
|
52
|
+
originalSource.source = templateHandler(oldVal, {
|
|
53
|
+
runtimeSet
|
|
54
|
+
});
|
|
55
|
+
onUpdate(file, oldVal, originalSource.source);
|
|
56
|
+
debug('html handle: %s', file);
|
|
57
|
+
noCachedCount++;
|
|
58
|
+
return {
|
|
59
|
+
key: file,
|
|
60
|
+
source: originalSource.source
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
debug('html handle finish, total: %d, no-cached: %d', groupedEntries.html.length, noCachedCount);
|
|
65
|
+
}
|
|
66
|
+
if (Array.isArray(groupedEntries.js)) {
|
|
67
|
+
let noCachedCount = 0;
|
|
68
|
+
for (let i = 0; i < groupedEntries.js.length; i++) {
|
|
69
|
+
const [file, originalSource] = groupedEntries.js[i];
|
|
70
|
+
const rawSource = originalSource.code;
|
|
71
|
+
const hash = cache.computeHash(rawSource);
|
|
72
|
+
cache.calcHashValueChanged(file, hash);
|
|
73
|
+
yield cache.process(file, () => {
|
|
74
|
+
const source = cache.get(file);
|
|
75
|
+
if (source) {
|
|
76
|
+
originalSource.code = source;
|
|
77
|
+
debug('js cache hit: %s', file);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
}, () => {
|
|
83
|
+
const mapFilename = file + '.map';
|
|
84
|
+
const hasMap = Boolean(bundle[mapFilename]);
|
|
85
|
+
const { code, map } = jsHandler(rawSource, runtimeSet, {
|
|
86
|
+
generateMap: hasMap
|
|
87
|
+
});
|
|
88
|
+
originalSource.code = code;
|
|
89
|
+
onUpdate(file, rawSource, code);
|
|
90
|
+
debug('js handle: %s', file);
|
|
91
|
+
noCachedCount++;
|
|
92
|
+
if (hasMap && map) {
|
|
93
|
+
bundle[mapFilename].source = map.toString();
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
key: file,
|
|
97
|
+
source: code
|
|
98
|
+
};
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
debug('js handle finish, total: %d, no-cached: %d', groupedEntries.js.length, noCachedCount);
|
|
102
|
+
}
|
|
103
|
+
if (Array.isArray(groupedEntries.css)) {
|
|
104
|
+
let noCachedCount = 0;
|
|
105
|
+
for (let i = 0; i < groupedEntries.css.length; i++) {
|
|
106
|
+
const [file, originalSource] = groupedEntries.css[i];
|
|
107
|
+
const rawSource = originalSource.source.toString();
|
|
108
|
+
const hash = cache.computeHash(rawSource);
|
|
109
|
+
cache.calcHashValueChanged(file, hash);
|
|
110
|
+
yield cache.process(file, () => {
|
|
111
|
+
const source = cache.get(file);
|
|
112
|
+
if (source) {
|
|
113
|
+
originalSource.source = source;
|
|
114
|
+
debug('css cache hit: %s', file);
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
}, () => options.__awaiter(this, void 0, void 0, function* () {
|
|
120
|
+
const css = yield styleHandler(rawSource, {
|
|
121
|
+
isMainChunk: mainCssChunkMatcher(originalSource.fileName, appType)
|
|
122
|
+
});
|
|
123
|
+
originalSource.source = css;
|
|
124
|
+
onUpdate(file, rawSource, css);
|
|
125
|
+
debug('css handle: %s', file);
|
|
126
|
+
noCachedCount++;
|
|
127
|
+
return {
|
|
128
|
+
key: file,
|
|
129
|
+
source: css
|
|
130
|
+
};
|
|
131
|
+
}));
|
|
132
|
+
}
|
|
133
|
+
debug('css handle finish, total: %d, no-cached: %d', groupedEntries.css.length, noCachedCount);
|
|
134
|
+
}
|
|
135
|
+
onEnd();
|
|
136
|
+
debug('end');
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
exports.UnifiedViteWeappTailwindcssPlugin = UnifiedViteWeappTailwindcssPlugin;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { g as getOptions, c as createTailwindcssPatcher, _ as __awaiter } from './options-6YPFqoRJ.mjs';
|
|
2
|
+
import { v as vitePluginName } from './index-_74RBzwy.mjs';
|
|
3
|
+
import { g as getGroupedEntries } from './defaults-TZpmwtzd.mjs';
|
|
4
|
+
import { c as createDebug } from './index-06BoOZig.mjs';
|
|
5
|
+
|
|
6
|
+
const debug = createDebug('generateBundle: ');
|
|
7
|
+
function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
8
|
+
if (options.customReplaceDictionary === undefined) {
|
|
9
|
+
options.customReplaceDictionary = 'simple';
|
|
10
|
+
}
|
|
11
|
+
const opts = getOptions(options);
|
|
12
|
+
const { disabled, onEnd, onLoad, onStart, onUpdate, templateHandler, styleHandler, patch, jsHandler, mainCssChunkMatcher, appType, setMangleRuntimeSet, cache, tailwindcssBasedir } = opts;
|
|
13
|
+
if (disabled) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
patch === null || patch === void 0 ? void 0 : patch();
|
|
17
|
+
const twPatcher = createTailwindcssPatcher();
|
|
18
|
+
onLoad();
|
|
19
|
+
return {
|
|
20
|
+
name: vitePluginName,
|
|
21
|
+
enforce: 'post',
|
|
22
|
+
generateBundle(opt, bundle) {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
debug('start');
|
|
25
|
+
onStart();
|
|
26
|
+
const entries = Object.entries(bundle);
|
|
27
|
+
const groupedEntries = getGroupedEntries(entries, opts);
|
|
28
|
+
const runtimeSet = twPatcher.getClassSet({
|
|
29
|
+
basedir: tailwindcssBasedir
|
|
30
|
+
});
|
|
31
|
+
setMangleRuntimeSet(runtimeSet);
|
|
32
|
+
debug('get runtimeSet, class count: %d', runtimeSet.size);
|
|
33
|
+
if (Array.isArray(groupedEntries.html)) {
|
|
34
|
+
let noCachedCount = 0;
|
|
35
|
+
for (let i = 0; i < groupedEntries.html.length; i++) {
|
|
36
|
+
const [file, originalSource] = groupedEntries.html[i];
|
|
37
|
+
const oldVal = originalSource.source.toString();
|
|
38
|
+
const hash = cache.computeHash(oldVal);
|
|
39
|
+
cache.calcHashValueChanged(file, hash);
|
|
40
|
+
yield cache.process(file, () => {
|
|
41
|
+
const source = cache.get(file);
|
|
42
|
+
if (source) {
|
|
43
|
+
originalSource.source = source;
|
|
44
|
+
debug('html cache hit: %s', file);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
}, () => {
|
|
50
|
+
originalSource.source = templateHandler(oldVal, {
|
|
51
|
+
runtimeSet
|
|
52
|
+
});
|
|
53
|
+
onUpdate(file, oldVal, originalSource.source);
|
|
54
|
+
debug('html handle: %s', file);
|
|
55
|
+
noCachedCount++;
|
|
56
|
+
return {
|
|
57
|
+
key: file,
|
|
58
|
+
source: originalSource.source
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
debug('html handle finish, total: %d, no-cached: %d', groupedEntries.html.length, noCachedCount);
|
|
63
|
+
}
|
|
64
|
+
if (Array.isArray(groupedEntries.js)) {
|
|
65
|
+
let noCachedCount = 0;
|
|
66
|
+
for (let i = 0; i < groupedEntries.js.length; i++) {
|
|
67
|
+
const [file, originalSource] = groupedEntries.js[i];
|
|
68
|
+
const rawSource = originalSource.code;
|
|
69
|
+
const hash = cache.computeHash(rawSource);
|
|
70
|
+
cache.calcHashValueChanged(file, hash);
|
|
71
|
+
yield cache.process(file, () => {
|
|
72
|
+
const source = cache.get(file);
|
|
73
|
+
if (source) {
|
|
74
|
+
originalSource.code = source;
|
|
75
|
+
debug('js cache hit: %s', file);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
}, () => {
|
|
81
|
+
const mapFilename = file + '.map';
|
|
82
|
+
const hasMap = Boolean(bundle[mapFilename]);
|
|
83
|
+
const { code, map } = jsHandler(rawSource, runtimeSet, {
|
|
84
|
+
generateMap: hasMap
|
|
85
|
+
});
|
|
86
|
+
originalSource.code = code;
|
|
87
|
+
onUpdate(file, rawSource, code);
|
|
88
|
+
debug('js handle: %s', file);
|
|
89
|
+
noCachedCount++;
|
|
90
|
+
if (hasMap && map) {
|
|
91
|
+
bundle[mapFilename].source = map.toString();
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
key: file,
|
|
95
|
+
source: code
|
|
96
|
+
};
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
debug('js handle finish, total: %d, no-cached: %d', groupedEntries.js.length, noCachedCount);
|
|
100
|
+
}
|
|
101
|
+
if (Array.isArray(groupedEntries.css)) {
|
|
102
|
+
let noCachedCount = 0;
|
|
103
|
+
for (let i = 0; i < groupedEntries.css.length; i++) {
|
|
104
|
+
const [file, originalSource] = groupedEntries.css[i];
|
|
105
|
+
const rawSource = originalSource.source.toString();
|
|
106
|
+
const hash = cache.computeHash(rawSource);
|
|
107
|
+
cache.calcHashValueChanged(file, hash);
|
|
108
|
+
yield cache.process(file, () => {
|
|
109
|
+
const source = cache.get(file);
|
|
110
|
+
if (source) {
|
|
111
|
+
originalSource.source = source;
|
|
112
|
+
debug('css cache hit: %s', file);
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
}, () => __awaiter(this, void 0, void 0, function* () {
|
|
118
|
+
const css = yield styleHandler(rawSource, {
|
|
119
|
+
isMainChunk: mainCssChunkMatcher(originalSource.fileName, appType)
|
|
120
|
+
});
|
|
121
|
+
originalSource.source = css;
|
|
122
|
+
onUpdate(file, rawSource, css);
|
|
123
|
+
debug('css handle: %s', file);
|
|
124
|
+
noCachedCount++;
|
|
125
|
+
return {
|
|
126
|
+
key: file,
|
|
127
|
+
source: css
|
|
128
|
+
};
|
|
129
|
+
}));
|
|
130
|
+
}
|
|
131
|
+
debug('css handle finish, total: %d, no-cached: %d', groupedEntries.css.length, noCachedCount);
|
|
132
|
+
}
|
|
133
|
+
onEnd();
|
|
134
|
+
debug('end');
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export { UnifiedViteWeappTailwindcssPlugin as U };
|
|
@@ -4,7 +4,7 @@ import selectorParser from 'postcss-selector-parser';
|
|
|
4
4
|
import { c as composeIsPseudo, i as internalCssSelectorReplacer } from './shared-0D5OOeXo.mjs';
|
|
5
5
|
import { Declaration, Rule } from 'postcss';
|
|
6
6
|
|
|
7
|
-
const
|
|
7
|
+
const createRuleTransform = (rule, options) => {
|
|
8
8
|
const { escapeMap, mangleContext, cssSelectorReplacement } = options;
|
|
9
9
|
const transform = (selectors) => {
|
|
10
10
|
selectors.walk((selector) => {
|
|
@@ -31,16 +31,45 @@ const createTransform = (rule, options) => {
|
|
|
31
31
|
};
|
|
32
32
|
return transform;
|
|
33
33
|
};
|
|
34
|
-
const
|
|
35
|
-
return selectorParser(
|
|
34
|
+
const getRuleTransformer = (rule, options) => {
|
|
35
|
+
return selectorParser(createRuleTransform(rule, options));
|
|
36
36
|
};
|
|
37
|
-
const
|
|
38
|
-
const transformer =
|
|
37
|
+
const ruleTransformSync = (rule, options) => {
|
|
38
|
+
const transformer = getRuleTransformer(rule, options);
|
|
39
39
|
return transformer.transformSync(rule, {
|
|
40
40
|
lossless: false,
|
|
41
41
|
updateSelector: true
|
|
42
42
|
});
|
|
43
43
|
};
|
|
44
|
+
function isOnlyBeforeAndAfterPseudoElement(node) {
|
|
45
|
+
let b = false;
|
|
46
|
+
let a = false;
|
|
47
|
+
selectorParser((selectors) => {
|
|
48
|
+
selectors.walkPseudos((s) => {
|
|
49
|
+
var _a;
|
|
50
|
+
if (((_a = s.parent) === null || _a === void 0 ? void 0 : _a.length) === 1) {
|
|
51
|
+
if (/^:?:before$/.test(s.value)) {
|
|
52
|
+
b = true;
|
|
53
|
+
}
|
|
54
|
+
if (/^:?:after$/.test(s.value)) {
|
|
55
|
+
a = true;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}).astSync(node);
|
|
60
|
+
return b && a;
|
|
61
|
+
}
|
|
62
|
+
const fallbackRemove = selectorParser((selectors) => {
|
|
63
|
+
selectors.walk((selector) => {
|
|
64
|
+
var _a, _b;
|
|
65
|
+
if (selector.type === 'universal') {
|
|
66
|
+
(_a = selector.parent) === null || _a === void 0 ? void 0 : _a.remove();
|
|
67
|
+
}
|
|
68
|
+
if (selector.type === 'pseudo' && selector.value === ':is') {
|
|
69
|
+
(_b = selector.parent) === null || _b === void 0 ? void 0 : _b.remove();
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
});
|
|
44
73
|
|
|
45
74
|
var cssVars = [
|
|
46
75
|
{
|
|
@@ -233,8 +262,6 @@ var cssVars = [
|
|
|
233
262
|
}
|
|
234
263
|
];
|
|
235
264
|
|
|
236
|
-
const VariablesScopeSymbol = Symbol('VariablesScope');
|
|
237
|
-
|
|
238
265
|
const initialNodes = cssVars.map((x) => {
|
|
239
266
|
return new Declaration({
|
|
240
267
|
prop: x.prop,
|
|
@@ -244,7 +271,7 @@ const initialNodes = cssVars.map((x) => {
|
|
|
244
271
|
const PATTERNS = [/:not\(template\)\s*[~+]\s*:not\(template\)/.source, /:not\(\[hidden\]\)\s*[~+]\s*:not\(\[hidden\]\)/.source].join('|');
|
|
245
272
|
const BROAD_MATCH_GLOBAL_REGEXP = new RegExp(PATTERNS, 'g');
|
|
246
273
|
function testIfVariablesScope(node, count = 2) {
|
|
247
|
-
if (
|
|
274
|
+
if (isOnlyBeforeAndAfterPseudoElement(node)) {
|
|
248
275
|
const nodes = node.nodes;
|
|
249
276
|
let c = 0;
|
|
250
277
|
for (const tryTestDecl of nodes) {
|
|
@@ -321,7 +348,7 @@ function commonChunkPreflight(node, options) {
|
|
|
321
348
|
const { ctx, cssChildCombinatorReplaceValue, cssInjectPreflight, injectAdditionalCssVarScope } = options;
|
|
322
349
|
node.selector = remakeCombinatorSelector(node.selector, cssChildCombinatorReplaceValue);
|
|
323
350
|
if (testIfVariablesScope(node)) {
|
|
324
|
-
ctx === null || ctx === void 0 ? void 0 : ctx.
|
|
351
|
+
ctx === null || ctx === void 0 ? void 0 : ctx.markVariablesScope(node);
|
|
325
352
|
node.selectors = remakeCssVarSelector(node.selectors, options);
|
|
326
353
|
node.before(makePseudoVarRule());
|
|
327
354
|
if (typeof cssInjectPreflight === 'function') {
|
|
@@ -345,6 +372,7 @@ function commonChunkPreflight(node, options) {
|
|
|
345
372
|
const postcssPlugin = 'postcss-weapp-tailwindcss-rename-plugin';
|
|
346
373
|
const pluginName = 'weapp-tailwindcss-webpack-plugin';
|
|
347
374
|
const vitePluginName = 'vite-plugin-uni-app-weapp-tailwindcss-adaptor';
|
|
375
|
+
const WEAPP_TW_REQUIRED_NODE_VERSION = '16.6.0';
|
|
348
376
|
|
|
349
377
|
function isAtMediaHover(atRule) {
|
|
350
378
|
return /media\(\s*hover\s*:\s*hover\s*\)/.test(atRule.name) || (atRule.name === 'media' && /\(\s*hover\s*:\s*hover\s*\)/.test(atRule.params));
|
|
@@ -356,7 +384,7 @@ const postcssWeappTailwindcssPrePlugin = (options = {
|
|
|
356
384
|
const p = {
|
|
357
385
|
postcssPlugin,
|
|
358
386
|
Rule(rule) {
|
|
359
|
-
|
|
387
|
+
ruleTransformSync(rule, options);
|
|
360
388
|
},
|
|
361
389
|
AtRule(atRule) {
|
|
362
390
|
if (isAtMediaHover(atRule)) {
|
|
@@ -376,17 +404,6 @@ const postcssWeappTailwindcssPrePlugin = (options = {
|
|
|
376
404
|
};
|
|
377
405
|
postcssWeappTailwindcssPrePlugin.postcss = true;
|
|
378
406
|
|
|
379
|
-
const fallback = selectorParser((selectors) => {
|
|
380
|
-
selectors.walk((selector) => {
|
|
381
|
-
var _a, _b;
|
|
382
|
-
if (selector.type === 'universal') {
|
|
383
|
-
(_a = selector.parent) === null || _a === void 0 ? void 0 : _a.remove();
|
|
384
|
-
}
|
|
385
|
-
if (selector.type === 'pseudo' && selector.value === ':is') {
|
|
386
|
-
(_b = selector.parent) === null || _b === void 0 ? void 0 : _b.remove();
|
|
387
|
-
}
|
|
388
|
-
});
|
|
389
|
-
});
|
|
390
407
|
const postcssWeappTailwindcssPostPlugin = (options = {
|
|
391
408
|
isMainChunk: true
|
|
392
409
|
}) => {
|
|
@@ -398,15 +415,15 @@ const postcssWeappTailwindcssPostPlugin = (options = {
|
|
|
398
415
|
p.OnceExit = (root) => {
|
|
399
416
|
root.walkRules((rule) => {
|
|
400
417
|
if (ctx) {
|
|
401
|
-
if (ctx.
|
|
402
|
-
|
|
418
|
+
if (ctx.isVariablesScope(rule)) {
|
|
419
|
+
fallbackRemove.transformSync(rule, {
|
|
403
420
|
updateSelector: true,
|
|
404
421
|
lossless: false
|
|
405
422
|
});
|
|
406
423
|
}
|
|
407
424
|
}
|
|
408
425
|
else if (testIfVariablesScope(rule)) {
|
|
409
|
-
|
|
426
|
+
fallbackRemove.transformSync(rule, {
|
|
410
427
|
updateSelector: true,
|
|
411
428
|
lossless: false
|
|
412
429
|
});
|
|
@@ -423,9 +440,20 @@ const postcssWeappTailwindcssPostPlugin = (options = {
|
|
|
423
440
|
};
|
|
424
441
|
postcssWeappTailwindcssPostPlugin.postcss = true;
|
|
425
442
|
|
|
443
|
+
const VariablesScopeSymbol = Symbol('VariablesScope');
|
|
444
|
+
|
|
426
445
|
function createContext() {
|
|
446
|
+
const variablesScopeWeakMap = new WeakMap();
|
|
447
|
+
function isVariablesScope(rule) {
|
|
448
|
+
return variablesScopeWeakMap.get(rule) === VariablesScopeSymbol;
|
|
449
|
+
}
|
|
450
|
+
function markVariablesScope(rule) {
|
|
451
|
+
variablesScopeWeakMap.set(rule, VariablesScopeSymbol);
|
|
452
|
+
}
|
|
427
453
|
return {
|
|
428
|
-
variablesScopeWeakMap
|
|
454
|
+
variablesScopeWeakMap,
|
|
455
|
+
isVariablesScope,
|
|
456
|
+
markVariablesScope
|
|
429
457
|
};
|
|
430
458
|
}
|
|
431
459
|
|
|
@@ -451,4 +479,4 @@ function getPlugins(options) {
|
|
|
451
479
|
return plugins;
|
|
452
480
|
}
|
|
453
481
|
|
|
454
|
-
export {
|
|
482
|
+
export { WEAPP_TW_REQUIRED_NODE_VERSION as W, postcssWeappTailwindcssPrePlugin as a, pluginName as b, getPlugins as g, postcssWeappTailwindcssPostPlugin as p, vitePluginName as v };
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var _createDebug = require('debug');
|
|
4
4
|
|
|
5
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : {
|
|
5
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
6
6
|
|
|
7
7
|
var _createDebug__default = /*#__PURE__*/_interopDefaultCompat(_createDebug);
|
|
8
8
|
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { g as getOptions, c as createTailwindcssPatcher, _ as __awaiter } from './options-6YPFqoRJ.mjs';
|
|
2
|
+
import stream from 'node:stream';
|
|
3
|
+
|
|
4
|
+
const Transform = stream.Transform;
|
|
5
|
+
function createPlugins(options = {}) {
|
|
6
|
+
const opts = getOptions(options);
|
|
7
|
+
const { templateHandler, styleHandler, patch, jsHandler, setMangleRuntimeSet, tailwindcssBasedir } = opts;
|
|
8
|
+
let runtimeSet = new Set();
|
|
9
|
+
patch === null || patch === void 0 ? void 0 : patch();
|
|
10
|
+
const twPatcher = createTailwindcssPatcher();
|
|
11
|
+
function transformWxss() {
|
|
12
|
+
const transformStream = new Transform({ objectMode: true });
|
|
13
|
+
transformStream._transform = function (file, encoding, callback) {
|
|
14
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
runtimeSet = twPatcher.getClassSet({
|
|
16
|
+
basedir: tailwindcssBasedir
|
|
17
|
+
});
|
|
18
|
+
setMangleRuntimeSet(runtimeSet);
|
|
19
|
+
const error = null;
|
|
20
|
+
if (file.contents) {
|
|
21
|
+
const code = yield styleHandler(file.contents.toString(), {
|
|
22
|
+
isMainChunk: true
|
|
23
|
+
});
|
|
24
|
+
file.contents = Buffer.from(code);
|
|
25
|
+
}
|
|
26
|
+
callback(error, file);
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
return transformStream;
|
|
30
|
+
}
|
|
31
|
+
function transformJs() {
|
|
32
|
+
const transformStream = new Transform({ objectMode: true });
|
|
33
|
+
transformStream._transform = function (file, encoding, callback) {
|
|
34
|
+
const error = null;
|
|
35
|
+
if (file.contents) {
|
|
36
|
+
const { code } = jsHandler(file.contents.toString(), runtimeSet);
|
|
37
|
+
file.contents = Buffer.from(code);
|
|
38
|
+
}
|
|
39
|
+
callback(error, file);
|
|
40
|
+
};
|
|
41
|
+
return transformStream;
|
|
42
|
+
}
|
|
43
|
+
function transformWxml() {
|
|
44
|
+
const transformStream = new Transform({ objectMode: true });
|
|
45
|
+
transformStream._transform = function (file, encoding, callback) {
|
|
46
|
+
const error = null;
|
|
47
|
+
if (file.contents) {
|
|
48
|
+
const code = templateHandler(file.contents.toString(), {
|
|
49
|
+
runtimeSet
|
|
50
|
+
});
|
|
51
|
+
file.contents = Buffer.from(code);
|
|
52
|
+
}
|
|
53
|
+
callback(error, file);
|
|
54
|
+
};
|
|
55
|
+
return transformStream;
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
transformWxss,
|
|
59
|
+
transformWxml,
|
|
60
|
+
transformJs
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export { createPlugins as c };
|
package/dist/index.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
require('./options-
|
|
5
|
+
var v5 = require('./v5-RkdOexPP.js');
|
|
6
|
+
var index = require('./index-KpA8Y68V.js');
|
|
7
|
+
var index$1 = require('./index-8OJKpYld.js');
|
|
8
|
+
require('./options-N9g3FpWO.js');
|
|
9
9
|
require('magic-string');
|
|
10
10
|
require('./replace.js');
|
|
11
11
|
require('@weapp-core/escape');
|
|
@@ -20,7 +20,7 @@ require('./defu-KWuJnZLV.js');
|
|
|
20
20
|
require('@babel/types');
|
|
21
21
|
require('htmlparser2');
|
|
22
22
|
require('postcss');
|
|
23
|
-
require('./
|
|
23
|
+
require('./index-Fkmyt0Rc.js');
|
|
24
24
|
require('@csstools/postcss-is-pseudo-class');
|
|
25
25
|
require('postcss-rem-to-responsive-pixel');
|
|
26
26
|
require('postcss-selector-parser');
|
|
@@ -31,12 +31,12 @@ require('tailwindcss-patch');
|
|
|
31
31
|
require('@tailwindcss-mangle/shared');
|
|
32
32
|
require('lru-cache');
|
|
33
33
|
require('md5');
|
|
34
|
-
require('./index-
|
|
34
|
+
require('./index-juOeq2Kt.js');
|
|
35
35
|
require('debug');
|
|
36
36
|
require('node:stream');
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
|
|
40
|
-
exports.UnifiedWebpackPluginV5 =
|
|
41
|
-
exports.UnifiedViteWeappTailwindcssPlugin =
|
|
42
|
-
exports.createPlugins =
|
|
40
|
+
exports.UnifiedWebpackPluginV5 = v5.UnifiedWebpackPluginV5;
|
|
41
|
+
exports.UnifiedViteWeappTailwindcssPlugin = index.UnifiedViteWeappTailwindcssPlugin;
|
|
42
|
+
exports.createPlugins = index$1.createPlugins;
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { UnifiedWebpackPluginV5 } from './
|
|
2
|
-
export { UnifiedViteWeappTailwindcssPlugin } from './
|
|
3
|
-
export { createPlugins } from './
|
|
4
|
-
import './options-
|
|
1
|
+
export { U as UnifiedWebpackPluginV5 } from './v5-UTJ5AaEA.mjs';
|
|
2
|
+
export { U as UnifiedViteWeappTailwindcssPlugin } from './index-O8jpXUxP.mjs';
|
|
3
|
+
export { c as createPlugins } from './index-u-U9HdG6.mjs';
|
|
4
|
+
import './options-6YPFqoRJ.mjs';
|
|
5
5
|
import 'magic-string';
|
|
6
6
|
import './replace.mjs';
|
|
7
7
|
import '@weapp-core/escape';
|
|
@@ -16,7 +16,7 @@ import './defu-ms_ZBCiB.mjs';
|
|
|
16
16
|
import '@babel/types';
|
|
17
17
|
import 'htmlparser2';
|
|
18
18
|
import 'postcss';
|
|
19
|
-
import './
|
|
19
|
+
import './index-_74RBzwy.mjs';
|
|
20
20
|
import '@csstools/postcss-is-pseudo-class';
|
|
21
21
|
import 'postcss-rem-to-responsive-pixel';
|
|
22
22
|
import 'postcss-selector-parser';
|
|
@@ -10,7 +10,7 @@ import { d as defuOverrideArray, n as noop, a as defaultOptions, i as isMap } fr
|
|
|
10
10
|
import * as t from '@babel/types';
|
|
11
11
|
import { Parser } from 'htmlparser2';
|
|
12
12
|
import postcss from 'postcss';
|
|
13
|
-
import { g as getPlugins } from './
|
|
13
|
+
import { g as getPlugins } from './index-_74RBzwy.mjs';
|
|
14
14
|
import path from 'node:path';
|
|
15
15
|
import fs from 'node:fs';
|
|
16
16
|
import { gte } from 'semver';
|
|
@@ -687,4 +687,4 @@ function getOptions(options = {}) {
|
|
|
687
687
|
return result;
|
|
688
688
|
}
|
|
689
689
|
|
|
690
|
-
export { __awaiter as _,
|
|
690
|
+
export { __awaiter as _, createPatch as a, createTailwindcssPatcher as c, getOptions as g };
|
|
@@ -12,7 +12,7 @@ var defaults = require('./defaults-QOAV8NSV.js');
|
|
|
12
12
|
var t = require('@babel/types');
|
|
13
13
|
var htmlparser2 = require('htmlparser2');
|
|
14
14
|
var postcss = require('postcss');
|
|
15
|
-
var
|
|
15
|
+
var index = require('./index-Fkmyt0Rc.js');
|
|
16
16
|
var path = require('node:path');
|
|
17
17
|
var fs = require('node:fs');
|
|
18
18
|
var semver = require('semver');
|
|
@@ -21,7 +21,7 @@ var shared = require('@tailwindcss-mangle/shared');
|
|
|
21
21
|
var lruCache = require('lru-cache');
|
|
22
22
|
var md5 = require('md5');
|
|
23
23
|
|
|
24
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : {
|
|
24
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
25
25
|
|
|
26
26
|
function _interopNamespaceCompat(e) {
|
|
27
27
|
if (e && typeof e === 'object' && 'default' in e) return e;
|
|
@@ -394,7 +394,7 @@ function createTemplateHandler(options = {}) {
|
|
|
394
394
|
|
|
395
395
|
function styleHandler(rawSource, options) {
|
|
396
396
|
return __awaiter(this, void 0, void 0, function* () {
|
|
397
|
-
return (yield postcss__default["default"](
|
|
397
|
+
return (yield postcss__default["default"](index.getPlugins(options)).process(rawSource).async()).css;
|
|
398
398
|
});
|
|
399
399
|
}
|
|
400
400
|
function createStyleHandler(options) {
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import selectorParser from 'postcss-selector-parser';
|
|
1
2
|
import type { Rule } from 'postcss';
|
|
2
3
|
import type { IStyleHandlerOptions } from "../types";
|
|
3
|
-
export declare const
|
|
4
|
+
export declare const ruleTransformSync: (rule: Rule, options: IStyleHandlerOptions) => void;
|
|
5
|
+
export declare function isOnlyBeforeAndAfterPseudoElement(node: Rule): boolean;
|
|
6
|
+
export declare const fallbackRemove: selectorParser.Processor<void, selectorParser.Selectors>;
|