tailwindcss-injector 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/postcss.cjs +12 -3
- package/dist/postcss.d.cts +1 -0
- package/dist/postcss.d.ts +1 -0
- package/dist/postcss.js +12 -3
- package/package.json +2 -2
package/dist/postcss.cjs
CHANGED
|
@@ -329,9 +329,12 @@ function getDefaultConfig() {
|
|
|
329
329
|
return {
|
|
330
330
|
filter: () => true,
|
|
331
331
|
config: void 0,
|
|
332
|
+
// 倒叙插入
|
|
332
333
|
directiveParams: ["utilities", "components"],
|
|
333
334
|
cwd: _process2.default.cwd(),
|
|
334
|
-
extensions: ["wxml", "js", "ts"]
|
|
335
|
+
extensions: ["wxml", "js", "ts"],
|
|
336
|
+
// @import and @use (scss)
|
|
337
|
+
insertAfterAtRulesNames: ["import", "use"]
|
|
335
338
|
};
|
|
336
339
|
}
|
|
337
340
|
function getConfig(options) {
|
|
@@ -440,7 +443,7 @@ async function getDepFiles(file) {
|
|
|
440
443
|
|
|
441
444
|
// src/postcss.ts
|
|
442
445
|
var creator = (options) => {
|
|
443
|
-
const { config, filter, directiveParams, cwd, extensions } = getConfig(options);
|
|
446
|
+
const { config, filter, directiveParams, cwd, extensions, insertAfterAtRulesNames } = getConfig(options);
|
|
444
447
|
const extensionsGlob = `{${extensions.join(",")}}`;
|
|
445
448
|
return {
|
|
446
449
|
postcssPlugin,
|
|
@@ -449,10 +452,16 @@ var creator = (options) => {
|
|
|
449
452
|
postcssPlugin: `${postcssPlugin}:post`,
|
|
450
453
|
async Once(root, helpers) {
|
|
451
454
|
if (filter(_optionalChain([root, 'access', _ => _.source, 'optionalAccess', _2 => _2.input]))) {
|
|
455
|
+
const lastIndex = root.nodes.findLastIndex((x) => x.type === "atrule" && insertAfterAtRulesNames.includes(x.name));
|
|
452
456
|
for (const params of directiveParams) {
|
|
453
457
|
const node = root.nodes.find((x) => x.type === "atrule" && x.params === params);
|
|
454
458
|
if (!node) {
|
|
455
|
-
|
|
459
|
+
const atRule = helpers.atRule({ name: "tailwind", params });
|
|
460
|
+
if (lastIndex < 0) {
|
|
461
|
+
root.prepend(atRule);
|
|
462
|
+
} else {
|
|
463
|
+
root.insertAfter(lastIndex, atRule);
|
|
464
|
+
}
|
|
456
465
|
}
|
|
457
466
|
}
|
|
458
467
|
const cfg = typeof config === "function" ? config(_optionalChain([root, 'access', _3 => _3.source, 'optionalAccess', _4 => _4.input])) : config;
|
package/dist/postcss.d.cts
CHANGED
|
@@ -8,6 +8,7 @@ interface Options {
|
|
|
8
8
|
config: InlineTailwindcssOptions | ((input?: postcss.Input) => InlineTailwindcssOptions);
|
|
9
9
|
directiveParams: ('base' | 'components' | 'utilities' | 'variants')[];
|
|
10
10
|
extensions: string[];
|
|
11
|
+
insertAfterAtRulesNames: string[];
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
declare const creator: PluginCreator<Partial<Options>>;
|
package/dist/postcss.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ interface Options {
|
|
|
8
8
|
config: InlineTailwindcssOptions | ((input?: postcss.Input) => InlineTailwindcssOptions);
|
|
9
9
|
directiveParams: ('base' | 'components' | 'utilities' | 'variants')[];
|
|
10
10
|
extensions: string[];
|
|
11
|
+
insertAfterAtRulesNames: string[];
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
declare const creator: PluginCreator<Partial<Options>>;
|
package/dist/postcss.js
CHANGED
|
@@ -329,9 +329,12 @@ function getDefaultConfig() {
|
|
|
329
329
|
return {
|
|
330
330
|
filter: () => true,
|
|
331
331
|
config: void 0,
|
|
332
|
+
// 倒叙插入
|
|
332
333
|
directiveParams: ["utilities", "components"],
|
|
333
334
|
cwd: process.cwd(),
|
|
334
|
-
extensions: ["wxml", "js", "ts"]
|
|
335
|
+
extensions: ["wxml", "js", "ts"],
|
|
336
|
+
// @import and @use (scss)
|
|
337
|
+
insertAfterAtRulesNames: ["import", "use"]
|
|
335
338
|
};
|
|
336
339
|
}
|
|
337
340
|
function getConfig(options) {
|
|
@@ -440,7 +443,7 @@ async function getDepFiles(file) {
|
|
|
440
443
|
|
|
441
444
|
// src/postcss.ts
|
|
442
445
|
var creator = (options) => {
|
|
443
|
-
const { config, filter, directiveParams, cwd, extensions } = getConfig(options);
|
|
446
|
+
const { config, filter, directiveParams, cwd, extensions, insertAfterAtRulesNames } = getConfig(options);
|
|
444
447
|
const extensionsGlob = `{${extensions.join(",")}}`;
|
|
445
448
|
return {
|
|
446
449
|
postcssPlugin,
|
|
@@ -449,10 +452,16 @@ var creator = (options) => {
|
|
|
449
452
|
postcssPlugin: `${postcssPlugin}:post`,
|
|
450
453
|
async Once(root, helpers) {
|
|
451
454
|
if (filter(root.source?.input)) {
|
|
455
|
+
const lastIndex = root.nodes.findLastIndex((x) => x.type === "atrule" && insertAfterAtRulesNames.includes(x.name));
|
|
452
456
|
for (const params of directiveParams) {
|
|
453
457
|
const node = root.nodes.find((x) => x.type === "atrule" && x.params === params);
|
|
454
458
|
if (!node) {
|
|
455
|
-
|
|
459
|
+
const atRule = helpers.atRule({ name: "tailwind", params });
|
|
460
|
+
if (lastIndex < 0) {
|
|
461
|
+
root.prepend(atRule);
|
|
462
|
+
} else {
|
|
463
|
+
root.insertAfter(lastIndex, atRule);
|
|
464
|
+
}
|
|
456
465
|
}
|
|
457
466
|
}
|
|
458
467
|
const cfg = typeof config === "function" ? config(root.source?.input) : config;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tailwindcss-injector",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.4",
|
|
5
5
|
"description": "tsup(esbuild) build package template",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"fs-extra": "^11.2.0",
|
|
35
35
|
"htmlparser2": "^9.1.0",
|
|
36
|
-
"magic-string": "^0.30.
|
|
36
|
+
"magic-string": "^0.30.15",
|
|
37
37
|
"postcss": "^8.4.49",
|
|
38
38
|
"tailwindcss": "^3.4.16",
|
|
39
39
|
"tailwindcss-config": "0.0.0"
|