@tailwindcss/postcss 0.0.0-development.1 → 0.0.0-development.3
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.d.ts +5 -0
- package/dist/index.js +22 -18
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { PluginCreator } from 'postcss';
|
|
2
2
|
|
|
3
3
|
interface PluginOptions {
|
|
4
|
+
/**
|
|
5
|
+
* The directory to scan for Tailwind CSS files.
|
|
6
|
+
* Defaults to the current working directory.
|
|
7
|
+
*/
|
|
8
|
+
base?: string;
|
|
4
9
|
}
|
|
5
10
|
declare const _default: PluginCreator<PluginOptions>;
|
|
6
11
|
|
package/dist/index.js
CHANGED
|
@@ -1,20 +1,27 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true})
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }// src/index.ts
|
|
2
|
+
var _oxide = require('@tailwindcss/oxide');
|
|
2
3
|
require('postcss');
|
|
3
4
|
var _tailwindcss = require('tailwindcss');
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
function tailwindcss(opts = {}) {
|
|
6
|
+
let base = _nullishCoalesce(opts.base, () => ( process.cwd()));
|
|
6
7
|
return {
|
|
7
8
|
postcssPlugin: "tailwindcss-v4",
|
|
8
9
|
AtRule: {
|
|
10
|
+
import: async (atRule, { AtRule }) => {
|
|
11
|
+
let isTailwind = atRule.params === "'tailwindcss'" || atRule.params === '"tailwindcss"';
|
|
12
|
+
if (!isTailwind)
|
|
13
|
+
return;
|
|
14
|
+
atRule.replaceWith(new AtRule({ name: "tailwind" }));
|
|
15
|
+
},
|
|
16
|
+
// We must handle `@tailwind` because not all tools preserve `@import`
|
|
17
|
+
// at-rules and replace them with their content before we see them.
|
|
9
18
|
tailwind: async (atRule, { result, postcss }) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
let
|
|
16
|
-
console.timeEnd("Compile CSS");
|
|
17
|
-
for (let file of project.files) {
|
|
19
|
+
if (atRule.params !== void 0 && atRule.params !== "") {
|
|
20
|
+
throw atRule.error(`@tailwind does not accept any parameters.`);
|
|
21
|
+
}
|
|
22
|
+
let scanResult = _oxide.scanDir.call(void 0, { base, globs: true });
|
|
23
|
+
let css = _tailwindcss.optimizeCss.call(void 0, _tailwindcss.preflight + _tailwindcss.compile.call(void 0, scanResult.candidates));
|
|
24
|
+
for (let file of scanResult.files) {
|
|
18
25
|
result.messages.push({
|
|
19
26
|
type: "dependency",
|
|
20
27
|
plugin: "tailwindcss-v4",
|
|
@@ -22,20 +29,17 @@ function tailwindcss(opts) {
|
|
|
22
29
|
parent: result.opts.from
|
|
23
30
|
});
|
|
24
31
|
}
|
|
25
|
-
for (let { base, glob } of
|
|
32
|
+
for (let { base: base2, glob } of scanResult.globs) {
|
|
26
33
|
result.messages.push({
|
|
27
34
|
type: "dir-dependency",
|
|
28
35
|
plugin: "tailwindcss-v4",
|
|
29
|
-
dir:
|
|
36
|
+
dir: base2,
|
|
30
37
|
glob,
|
|
31
38
|
parent: result.opts.from
|
|
32
39
|
});
|
|
33
40
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
console.timeEnd("Parsing CSS");
|
|
37
|
-
atRule.replaceWith(result2);
|
|
38
|
-
console.timeEnd("Tailwind CSS");
|
|
41
|
+
let nodes = postcss.parse(css);
|
|
42
|
+
atRule.replaceWith(nodes);
|
|
39
43
|
}
|
|
40
44
|
}
|
|
41
45
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tailwindcss/postcss",
|
|
3
|
-
"version": "0.0.0-development.
|
|
3
|
+
"version": "0.0.0-development.3",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "tsup-node ./src/index.ts --format cjs --dts --cjsInterop --splitting",
|
|
6
6
|
"dev": "npm run build -- --watch"
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"tailwindcss": "0.0.0-development.
|
|
19
|
-
"@tailwindcss/oxide": "0.0.0-development.
|
|
18
|
+
"tailwindcss": "0.0.0-development.3",
|
|
19
|
+
"@tailwindcss/oxide": "0.0.0-development.3"
|
|
20
20
|
}
|
|
21
21
|
}
|