@tailwindcss/vite 0.0.0-development.5 → 0.0.0-oxide.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.mjs +50 -15
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -6,6 +6,12 @@ function tailwindcss() {
|
|
|
6
6
|
let server = null;
|
|
7
7
|
let candidates = /* @__PURE__ */ new Set();
|
|
8
8
|
let cssModules = /* @__PURE__ */ new Set();
|
|
9
|
+
let minify = false;
|
|
10
|
+
function isCssFile(id) {
|
|
11
|
+
let [filename] = id.split("?", 2);
|
|
12
|
+
let extension = path.extname(filename).slice(1);
|
|
13
|
+
return extension === "css";
|
|
14
|
+
}
|
|
9
15
|
function updateCssModules() {
|
|
10
16
|
if (!server)
|
|
11
17
|
return;
|
|
@@ -25,25 +31,29 @@ function tailwindcss() {
|
|
|
25
31
|
});
|
|
26
32
|
}
|
|
27
33
|
if (updates.length > 0) {
|
|
28
|
-
server.
|
|
34
|
+
server.hot.send({ type: "update", updates });
|
|
29
35
|
}
|
|
30
36
|
}
|
|
31
37
|
function scan(src, extension) {
|
|
38
|
+
let updated = false;
|
|
32
39
|
for (let candidate of scanFiles(
|
|
33
40
|
[{ content: src, extension }],
|
|
34
41
|
IO.Sequential | Parsing.Sequential
|
|
35
42
|
)) {
|
|
36
|
-
if (
|
|
37
|
-
|
|
43
|
+
if (!updated) {
|
|
44
|
+
if (candidates.has(candidate))
|
|
45
|
+
continue;
|
|
46
|
+
updated = true;
|
|
38
47
|
}
|
|
39
48
|
candidates.add(candidate);
|
|
40
49
|
}
|
|
50
|
+
return updated;
|
|
41
51
|
}
|
|
42
52
|
function generateCss(css) {
|
|
43
|
-
return optimizeCss(compile(css, Array.from(candidates)));
|
|
53
|
+
return optimizeCss(compile(css, Array.from(candidates)), { minify });
|
|
44
54
|
}
|
|
45
55
|
let initialScan = function() {
|
|
46
|
-
let delayInMs =
|
|
56
|
+
let delayInMs = 50;
|
|
47
57
|
let timer;
|
|
48
58
|
let resolve;
|
|
49
59
|
let resolved = false;
|
|
@@ -70,23 +80,26 @@ function tailwindcss() {
|
|
|
70
80
|
configureServer(_server) {
|
|
71
81
|
server = _server;
|
|
72
82
|
},
|
|
83
|
+
async configResolved(config) {
|
|
84
|
+
minify = config.build.cssMinify !== false;
|
|
85
|
+
},
|
|
73
86
|
// Scan index.html for candidates
|
|
74
87
|
transformIndexHtml(html) {
|
|
75
88
|
initialScan.tick();
|
|
76
|
-
scan(html, "html");
|
|
77
|
-
if (server) {
|
|
89
|
+
let updated = scan(html, "html");
|
|
90
|
+
if (server && updated) {
|
|
78
91
|
updateCssModules();
|
|
79
92
|
}
|
|
80
93
|
},
|
|
81
94
|
// Scan all other files for candidates
|
|
82
95
|
transform(src, id) {
|
|
96
|
+
initialScan.tick();
|
|
83
97
|
if (id.includes("/.vite/"))
|
|
84
98
|
return;
|
|
85
99
|
let [filename] = id.split("?", 2);
|
|
86
100
|
let extension = path.extname(filename).slice(1);
|
|
87
101
|
if (extension === "" || extension === "css")
|
|
88
102
|
return;
|
|
89
|
-
initialScan.tick();
|
|
90
103
|
scan(src, extension);
|
|
91
104
|
if (server) {
|
|
92
105
|
updateCssModules();
|
|
@@ -94,19 +107,41 @@ function tailwindcss() {
|
|
|
94
107
|
}
|
|
95
108
|
},
|
|
96
109
|
{
|
|
97
|
-
// Step 2: Generate CSS
|
|
98
|
-
name: "@tailwindcss/vite:generate",
|
|
110
|
+
// Step 2 (dev mode): Generate CSS
|
|
111
|
+
name: "@tailwindcss/vite:generate:serve",
|
|
112
|
+
apply: "serve",
|
|
99
113
|
async transform(src, id) {
|
|
100
|
-
|
|
101
|
-
let extension = path.extname(filename).slice(1);
|
|
102
|
-
if (extension !== "css")
|
|
103
|
-
return;
|
|
104
|
-
if (!src.includes("@tailwind"))
|
|
114
|
+
if (!isCssFile(id) || !src.includes("@tailwind"))
|
|
105
115
|
return;
|
|
106
116
|
cssModules.add(id);
|
|
107
117
|
await initialScan.complete;
|
|
108
118
|
return { code: generateCss(src) };
|
|
109
119
|
}
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
// Step 2 (full build): Generate CSS
|
|
123
|
+
name: "@tailwindcss/vite:generate:build",
|
|
124
|
+
enforce: "post",
|
|
125
|
+
apply: "build",
|
|
126
|
+
generateBundle(_options, bundle) {
|
|
127
|
+
for (let id in bundle) {
|
|
128
|
+
let item = bundle[id];
|
|
129
|
+
if (item.type !== "asset")
|
|
130
|
+
continue;
|
|
131
|
+
if (!isCssFile(id))
|
|
132
|
+
continue;
|
|
133
|
+
let rawSource = item.source;
|
|
134
|
+
let source;
|
|
135
|
+
if (rawSource instanceof Uint8Array) {
|
|
136
|
+
source = new TextDecoder().decode(rawSource);
|
|
137
|
+
} else {
|
|
138
|
+
source = rawSource;
|
|
139
|
+
}
|
|
140
|
+
if (source.includes("@tailwind")) {
|
|
141
|
+
item.source = generateCss(source);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
110
145
|
}
|
|
111
146
|
];
|
|
112
147
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tailwindcss/vite",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-oxide.1",
|
|
4
4
|
"description": "A utility-first CSS framework for rapidly building custom user interfaces.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "https://github.com/tailwindlabs/tailwindcss.git",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@tailwindcss/oxide": "^0.0.0-
|
|
20
|
-
"tailwindcss": "^0.0.0-
|
|
19
|
+
"@tailwindcss/oxide": "^0.0.0-oxide.1",
|
|
20
|
+
"tailwindcss": "^0.0.0-oxide.1"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@types/node": "^20.11.17",
|