@weapp-tailwindcss/postcss 1.0.22-alpha.0 → 1.1.0-alpha.1
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/index.js +31 -30
- package/dist/index.mjs +34 -33
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -59,6 +59,7 @@ function createContext() {
|
|
|
59
59
|
var postcssPlugin = "postcss-weapp-tailwindcss-rename-plugin";
|
|
60
60
|
|
|
61
61
|
// src/selectorParser.ts
|
|
62
|
+
|
|
62
63
|
var _postcssselectorparser = require('postcss-selector-parser'); var _postcssselectorparser2 = _interopRequireDefault(_postcssselectorparser);
|
|
63
64
|
|
|
64
65
|
// src/shared.ts
|
|
@@ -190,9 +191,6 @@ function createRuleTransform(rule, options) {
|
|
|
190
191
|
}
|
|
191
192
|
}
|
|
192
193
|
}
|
|
193
|
-
if (uniAppX) {
|
|
194
|
-
selector.remove();
|
|
195
|
-
}
|
|
196
194
|
} else if (selector.type === "combinator") {
|
|
197
195
|
if (selector.value === ">") {
|
|
198
196
|
const nodes2 = _optionalChain([selector, 'access', _5 => _5.parent, 'optionalAccess', _6 => _6.nodes]);
|
|
@@ -259,7 +257,8 @@ function isOnlyBeforeAndAfterPseudoElement(node) {
|
|
|
259
257
|
}).astSync(node);
|
|
260
258
|
return b && a;
|
|
261
259
|
}
|
|
262
|
-
function getFallbackRemove(rule) {
|
|
260
|
+
function getFallbackRemove(rule, options) {
|
|
261
|
+
const { uniAppX } = _shared.defuOverrideArray.call(void 0, options, {});
|
|
263
262
|
const fallbackRemove = _postcssselectorparser2.default.call(void 0, (selectors) => {
|
|
264
263
|
let maybeImportantId = false;
|
|
265
264
|
selectors.walk((selector, idx) => {
|
|
@@ -307,6 +306,10 @@ function getFallbackRemove(rule) {
|
|
|
307
306
|
if (res) {
|
|
308
307
|
selector.remove();
|
|
309
308
|
}
|
|
309
|
+
} else if (selector.type === "pseudo") {
|
|
310
|
+
if (uniAppX) {
|
|
311
|
+
selector.remove();
|
|
312
|
+
}
|
|
310
313
|
}
|
|
311
314
|
}
|
|
312
315
|
});
|
|
@@ -324,34 +327,32 @@ var postcssWeappTailwindcssPostPlugin = (options) => {
|
|
|
324
327
|
postcssPlugin
|
|
325
328
|
};
|
|
326
329
|
if (opts.isMainChunk) {
|
|
327
|
-
p.
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
lossless: false
|
|
332
|
-
});
|
|
333
|
-
if (rule.selectors.length === 0 || rule.selectors.length === 1 && rule.selector.trim() === "") {
|
|
334
|
-
rule.remove();
|
|
335
|
-
}
|
|
336
|
-
rule.walkDecls((decl) => {
|
|
337
|
-
if (decl.prop === "--tw-gradient-position" && decl.value.endsWith(OklabSuffix)) {
|
|
338
|
-
decl.value = decl.value.slice(0, decl.value.length - OklabSuffix.length);
|
|
339
|
-
} else if (/calc\(\s*infinity\s*\*\s*1px/.test(decl.value)) {
|
|
340
|
-
decl.value = "9999px";
|
|
341
|
-
}
|
|
342
|
-
});
|
|
343
|
-
if (opts.uniAppX) {
|
|
344
|
-
if (rule.nodes.length === 0) {
|
|
345
|
-
rule.remove();
|
|
346
|
-
}
|
|
347
|
-
}
|
|
330
|
+
p.RuleExit = (rule) => {
|
|
331
|
+
getFallbackRemove(rule, opts).transformSync(rule, {
|
|
332
|
+
updateSelector: true,
|
|
333
|
+
lossless: false
|
|
348
334
|
});
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
335
|
+
if (rule.selectors.length === 0 || rule.selectors.length === 1 && rule.selector.trim() === "") {
|
|
336
|
+
rule.remove();
|
|
337
|
+
}
|
|
338
|
+
if (opts.uniAppX) {
|
|
339
|
+
if (rule.nodes.length === 0) {
|
|
340
|
+
rule.remove();
|
|
352
341
|
}
|
|
353
|
-
|
|
354
|
-
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
p.DeclarationExit = (decl) => {
|
|
345
|
+
if (decl.prop === "--tw-gradient-position" && decl.value.endsWith(OklabSuffix)) {
|
|
346
|
+
decl.value = decl.value.slice(0, decl.value.length - OklabSuffix.length);
|
|
347
|
+
} else if (/calc\(\s*infinity\s*\*\s*1px/.test(decl.value)) {
|
|
348
|
+
decl.value = "9999px";
|
|
349
|
+
}
|
|
350
|
+
};
|
|
351
|
+
p.AtRuleExit = (atRule) => {
|
|
352
|
+
if (opts.cssRemoveProperty && atRule.name === "property") {
|
|
353
|
+
atRule.remove();
|
|
354
|
+
}
|
|
355
|
+
_optionalChain([atRule, 'access', _24 => _24.nodes, 'optionalAccess', _25 => _25.length]) === 0 && atRule.remove();
|
|
355
356
|
};
|
|
356
357
|
}
|
|
357
358
|
if (typeof opts.customRuleCallback === "function") {
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "./chunk-WAXGOBY2.mjs";
|
|
2
2
|
|
|
3
3
|
// src/handler.ts
|
|
4
|
-
import { defu as defu3, defuOverrideArray } from "@weapp-tailwindcss/shared";
|
|
4
|
+
import { defu as defu3, defuOverrideArray as defuOverrideArray2 } from "@weapp-tailwindcss/shared";
|
|
5
5
|
import postcss from "postcss";
|
|
6
6
|
|
|
7
7
|
// src/defaults.ts
|
|
@@ -59,6 +59,7 @@ import { defu } from "@weapp-tailwindcss/shared";
|
|
|
59
59
|
var postcssPlugin = "postcss-weapp-tailwindcss-rename-plugin";
|
|
60
60
|
|
|
61
61
|
// src/selectorParser.ts
|
|
62
|
+
import { defuOverrideArray } from "@weapp-tailwindcss/shared";
|
|
62
63
|
import psp from "postcss-selector-parser";
|
|
63
64
|
|
|
64
65
|
// src/shared.ts
|
|
@@ -190,9 +191,6 @@ function createRuleTransform(rule, options) {
|
|
|
190
191
|
}
|
|
191
192
|
}
|
|
192
193
|
}
|
|
193
|
-
if (uniAppX) {
|
|
194
|
-
selector.remove();
|
|
195
|
-
}
|
|
196
194
|
} else if (selector.type === "combinator") {
|
|
197
195
|
if (selector.value === ">") {
|
|
198
196
|
const nodes2 = selector.parent?.nodes;
|
|
@@ -259,7 +257,8 @@ function isOnlyBeforeAndAfterPseudoElement(node) {
|
|
|
259
257
|
}).astSync(node);
|
|
260
258
|
return b && a;
|
|
261
259
|
}
|
|
262
|
-
function getFallbackRemove(rule) {
|
|
260
|
+
function getFallbackRemove(rule, options) {
|
|
261
|
+
const { uniAppX } = defuOverrideArray(options, {});
|
|
263
262
|
const fallbackRemove = psp((selectors) => {
|
|
264
263
|
let maybeImportantId = false;
|
|
265
264
|
selectors.walk((selector, idx) => {
|
|
@@ -307,6 +306,10 @@ function getFallbackRemove(rule) {
|
|
|
307
306
|
if (res) {
|
|
308
307
|
selector.remove();
|
|
309
308
|
}
|
|
309
|
+
} else if (selector.type === "pseudo") {
|
|
310
|
+
if (uniAppX) {
|
|
311
|
+
selector.remove();
|
|
312
|
+
}
|
|
310
313
|
}
|
|
311
314
|
}
|
|
312
315
|
});
|
|
@@ -324,34 +327,32 @@ var postcssWeappTailwindcssPostPlugin = (options) => {
|
|
|
324
327
|
postcssPlugin
|
|
325
328
|
};
|
|
326
329
|
if (opts.isMainChunk) {
|
|
327
|
-
p.
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
lossless: false
|
|
332
|
-
});
|
|
333
|
-
if (rule.selectors.length === 0 || rule.selectors.length === 1 && rule.selector.trim() === "") {
|
|
334
|
-
rule.remove();
|
|
335
|
-
}
|
|
336
|
-
rule.walkDecls((decl) => {
|
|
337
|
-
if (decl.prop === "--tw-gradient-position" && decl.value.endsWith(OklabSuffix)) {
|
|
338
|
-
decl.value = decl.value.slice(0, decl.value.length - OklabSuffix.length);
|
|
339
|
-
} else if (/calc\(\s*infinity\s*\*\s*1px/.test(decl.value)) {
|
|
340
|
-
decl.value = "9999px";
|
|
341
|
-
}
|
|
342
|
-
});
|
|
343
|
-
if (opts.uniAppX) {
|
|
344
|
-
if (rule.nodes.length === 0) {
|
|
345
|
-
rule.remove();
|
|
346
|
-
}
|
|
347
|
-
}
|
|
330
|
+
p.RuleExit = (rule) => {
|
|
331
|
+
getFallbackRemove(rule, opts).transformSync(rule, {
|
|
332
|
+
updateSelector: true,
|
|
333
|
+
lossless: false
|
|
348
334
|
});
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
335
|
+
if (rule.selectors.length === 0 || rule.selectors.length === 1 && rule.selector.trim() === "") {
|
|
336
|
+
rule.remove();
|
|
337
|
+
}
|
|
338
|
+
if (opts.uniAppX) {
|
|
339
|
+
if (rule.nodes.length === 0) {
|
|
340
|
+
rule.remove();
|
|
352
341
|
}
|
|
353
|
-
|
|
354
|
-
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
p.DeclarationExit = (decl) => {
|
|
345
|
+
if (decl.prop === "--tw-gradient-position" && decl.value.endsWith(OklabSuffix)) {
|
|
346
|
+
decl.value = decl.value.slice(0, decl.value.length - OklabSuffix.length);
|
|
347
|
+
} else if (/calc\(\s*infinity\s*\*\s*1px/.test(decl.value)) {
|
|
348
|
+
decl.value = "9999px";
|
|
349
|
+
}
|
|
350
|
+
};
|
|
351
|
+
p.AtRuleExit = (atRule) => {
|
|
352
|
+
if (opts.cssRemoveProperty && atRule.name === "property") {
|
|
353
|
+
atRule.remove();
|
|
354
|
+
}
|
|
355
|
+
atRule.nodes?.length === 0 && atRule.remove();
|
|
355
356
|
};
|
|
356
357
|
}
|
|
357
358
|
if (typeof opts.customRuleCallback === "function") {
|
|
@@ -1289,7 +1290,7 @@ function styleHandler(rawSource, options) {
|
|
|
1289
1290
|
).async();
|
|
1290
1291
|
}
|
|
1291
1292
|
function createStyleHandler(options) {
|
|
1292
|
-
const cachedOptions =
|
|
1293
|
+
const cachedOptions = defuOverrideArray2(
|
|
1293
1294
|
options,
|
|
1294
1295
|
getDefaultOptions()
|
|
1295
1296
|
);
|
|
@@ -1297,7 +1298,7 @@ function createStyleHandler(options) {
|
|
|
1297
1298
|
return (rawSource, opt) => {
|
|
1298
1299
|
return styleHandler(
|
|
1299
1300
|
rawSource,
|
|
1300
|
-
|
|
1301
|
+
defuOverrideArray2(opt, cachedOptions)
|
|
1301
1302
|
);
|
|
1302
1303
|
};
|
|
1303
1304
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weapp-tailwindcss/postcss",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0-alpha.1",
|
|
4
4
|
"description": "@weapp-tailwindcss/postcss",
|
|
5
5
|
"author": "ice breaker <1324318532@qq.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@weapp-core/escape": "~4.0.1",
|
|
43
43
|
"postcss": "~8.5.6",
|
|
44
|
-
"postcss-preset-env": "^10.
|
|
44
|
+
"postcss-preset-env": "^10.3.0",
|
|
45
45
|
"postcss-rem-to-responsive-pixel": "~6.0.2",
|
|
46
46
|
"postcss-selector-parser": "~7.1.0",
|
|
47
47
|
"@weapp-tailwindcss/shared": "1.0.3"
|