@tailwindcss/vite 4.0.0-alpha.1 → 4.0.0-alpha.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/README.md +40 -0
- package/dist/index.mjs +1 -145
- package/package.json +4 -4
package/README.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://tailwindcss.com" target="_blank">
|
|
3
|
+
<picture>
|
|
4
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/tailwindlabs/tailwindcss/HEAD/.github/logo-dark.svg">
|
|
5
|
+
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/tailwindlabs/tailwindcss/HEAD/.github/logo-light.svg">
|
|
6
|
+
<img alt="Tailwind CSS" src="https://raw.githubusercontent.com/tailwindlabs/tailwindcss/HEAD/.github/logo-light.svg" width="350" height="70" style="max-width: 100%;">
|
|
7
|
+
</picture>
|
|
8
|
+
</a>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
A utility-first CSS framework for rapidly building custom user interfaces.
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
<p align="center">
|
|
16
|
+
<a href="https://github.com/tailwindlabs/tailwindcss/actions"><img src="https://img.shields.io/github/actions/workflow/status/tailwindlabs/tailwindcss/ci.yml?branch=next" alt="Build Status"></a>
|
|
17
|
+
<a href="https://www.npmjs.com/package/tailwindcss"><img src="https://img.shields.io/npm/dt/tailwindcss.svg" alt="Total Downloads"></a>
|
|
18
|
+
<a href="https://github.com/tailwindcss/tailwindcss/releases"><img src="https://img.shields.io/npm/v/tailwindcss.svg" alt="Latest Release"></a>
|
|
19
|
+
<a href="https://github.com/tailwindcss/tailwindcss/blob/master/LICENSE"><img src="https://img.shields.io/npm/l/tailwindcss.svg" alt="License"></a>
|
|
20
|
+
</p>
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Documentation
|
|
25
|
+
|
|
26
|
+
For full documentation, visit [tailwindcss.com](https://tailwindcss.com).
|
|
27
|
+
|
|
28
|
+
## Community
|
|
29
|
+
|
|
30
|
+
For help, discussion about best practices, or any other conversation that would benefit from being searchable:
|
|
31
|
+
|
|
32
|
+
[Discuss Tailwind CSS on GitHub](https://github.com/tailwindcss/tailwindcss/discussions)
|
|
33
|
+
|
|
34
|
+
For chatting with others using the framework:
|
|
35
|
+
|
|
36
|
+
[Join the Tailwind CSS Discord Server](https://discord.gg/7NF8GNe)
|
|
37
|
+
|
|
38
|
+
## Contributing
|
|
39
|
+
|
|
40
|
+
If you're interested in contributing to Tailwind CSS, please read our [contributing docs](https://github.com/tailwindcss/tailwindcss/blob/next/.github/CONTRIBUTING.md) **before submitting a pull request**.
|
package/dist/index.mjs
CHANGED
|
@@ -1,145 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { IO, Parsing, scanFiles } from "@tailwindcss/oxide";
|
|
3
|
-
import path from "path";
|
|
4
|
-
import { compile, optimizeCss } from "tailwindcss";
|
|
5
|
-
function tailwindcss() {
|
|
6
|
-
let server = null;
|
|
7
|
-
let candidates = /* @__PURE__ */ new Set();
|
|
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
|
-
}
|
|
15
|
-
function updateCssModules() {
|
|
16
|
-
if (!server)
|
|
17
|
-
return;
|
|
18
|
-
let updates = [];
|
|
19
|
-
for (let id of cssModules) {
|
|
20
|
-
let cssModule = server.moduleGraph.getModuleById(id);
|
|
21
|
-
if (!cssModule) {
|
|
22
|
-
console.log("Could not find css module", id);
|
|
23
|
-
continue;
|
|
24
|
-
}
|
|
25
|
-
server.moduleGraph.invalidateModule(cssModule);
|
|
26
|
-
updates.push({
|
|
27
|
-
type: `${cssModule.type}-update`,
|
|
28
|
-
path: cssModule.url,
|
|
29
|
-
acceptedPath: cssModule.url,
|
|
30
|
-
timestamp: Date.now()
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
if (updates.length > 0) {
|
|
34
|
-
server.hot.send({ type: "update", updates });
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
function scan(src, extension) {
|
|
38
|
-
let updated = false;
|
|
39
|
-
for (let candidate of scanFiles(
|
|
40
|
-
[{ content: src, extension }],
|
|
41
|
-
IO.Sequential | Parsing.Sequential
|
|
42
|
-
)) {
|
|
43
|
-
if (!updated) {
|
|
44
|
-
if (candidates.has(candidate))
|
|
45
|
-
continue;
|
|
46
|
-
updated = true;
|
|
47
|
-
}
|
|
48
|
-
candidates.add(candidate);
|
|
49
|
-
}
|
|
50
|
-
return updated;
|
|
51
|
-
}
|
|
52
|
-
function generateCss(css) {
|
|
53
|
-
return optimizeCss(compile(css, Array.from(candidates)), { minify });
|
|
54
|
-
}
|
|
55
|
-
let initialScan = (() => {
|
|
56
|
-
let delayInMs = 50;
|
|
57
|
-
let timer;
|
|
58
|
-
let resolve;
|
|
59
|
-
let resolved = false;
|
|
60
|
-
return {
|
|
61
|
-
tick() {
|
|
62
|
-
if (resolved)
|
|
63
|
-
return;
|
|
64
|
-
timer && clearTimeout(timer);
|
|
65
|
-
timer = setTimeout(resolve, delayInMs);
|
|
66
|
-
},
|
|
67
|
-
complete: new Promise((_resolve) => {
|
|
68
|
-
resolve = () => {
|
|
69
|
-
resolved = true;
|
|
70
|
-
_resolve();
|
|
71
|
-
};
|
|
72
|
-
})
|
|
73
|
-
};
|
|
74
|
-
})();
|
|
75
|
-
return [
|
|
76
|
-
{
|
|
77
|
-
// Step 1: Scan source files for candidates
|
|
78
|
-
name: "@tailwindcss/vite:scan",
|
|
79
|
-
enforce: "pre",
|
|
80
|
-
configureServer(_server) {
|
|
81
|
-
server = _server;
|
|
82
|
-
},
|
|
83
|
-
async configResolved(config) {
|
|
84
|
-
minify = config.build.cssMinify !== false;
|
|
85
|
-
},
|
|
86
|
-
// Scan index.html for candidates
|
|
87
|
-
transformIndexHtml(html) {
|
|
88
|
-
initialScan.tick();
|
|
89
|
-
let updated = scan(html, "html");
|
|
90
|
-
if (server && updated) {
|
|
91
|
-
updateCssModules();
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
// Scan all other files for candidates
|
|
95
|
-
transform(src, id) {
|
|
96
|
-
initialScan.tick();
|
|
97
|
-
if (id.includes("/.vite/"))
|
|
98
|
-
return;
|
|
99
|
-
let [filename] = id.split("?", 2);
|
|
100
|
-
let extension = path.extname(filename).slice(1);
|
|
101
|
-
if (extension === "" || extension === "css")
|
|
102
|
-
return;
|
|
103
|
-
scan(src, extension);
|
|
104
|
-
if (server) {
|
|
105
|
-
updateCssModules();
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
// Step 2 (dev mode): Generate CSS
|
|
111
|
-
name: "@tailwindcss/vite:generate:serve",
|
|
112
|
-
apply: "serve",
|
|
113
|
-
async transform(src, id) {
|
|
114
|
-
if (!isCssFile(id) || !src.includes("@tailwind"))
|
|
115
|
-
return;
|
|
116
|
-
cssModules.add(id);
|
|
117
|
-
await initialScan.complete;
|
|
118
|
-
return { code: generateCss(src) };
|
|
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 = rawSource instanceof Uint8Array ? new TextDecoder().decode(rawSource) : rawSource;
|
|
135
|
-
if (source.includes("@tailwind")) {
|
|
136
|
-
item.source = generateCss(source);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
];
|
|
142
|
-
}
|
|
143
|
-
export {
|
|
144
|
-
tailwindcss as default
|
|
145
|
-
};
|
|
1
|
+
import{IO as v,Parsing as y,scanFiles as w}from"@tailwindcss/oxide";import g from"path";import{compile as h,optimizeCss as S}from"tailwindcss";function x(){let s=null,l=new Set,a=new Set,u=!1;function d(e){let[t]=e.split("?",2);return g.extname(t).slice(1)==="css"}function c(){if(!s)return;let e=[];for(let t of a){let i=s.moduleGraph.getModuleById(t);if(!i){console.log("Could not find css module",t);continue}s.moduleGraph.invalidateModule(i),e.push({type:`${i.type}-update`,path:i.url,acceptedPath:i.url,timestamp:Date.now()})}e.length>0&&s.hot.send({type:"update",updates:e})}function f(e,t){let i=!1;for(let n of w([{content:e,extension:t}],v.Sequential|y.Sequential)){if(!i){if(l.has(n))continue;i=!0}l.add(n)}return i}function p(e){return S(h(e,Array.from(l)),{minify:u})}let o=(()=>{let e=50,t,i,n=!1;return{tick(){n||(t&&clearTimeout(t),t=setTimeout(i,e))},complete:new Promise(r=>{i=()=>{n=!0,r()}})}})();return[{name:"@tailwindcss/vite:scan",enforce:"pre",configureServer(e){s=e},async configResolved(e){u=e.build.cssMinify!==!1},transformIndexHtml(e){o.tick();let t=f(e,"html");s&&t&&c()},transform(e,t){if(o.tick(),t.includes("/.vite/"))return;let[i]=t.split("?",2),n=g.extname(i).slice(1);n===""||n==="css"||(f(e,n),s&&c())}},{name:"@tailwindcss/vite:generate:serve",apply:"serve",async transform(e,t){if(!(!d(t)||!e.includes("@tailwind")))return a.add(t),await o.complete,{code:p(e)}}},{name:"@tailwindcss/vite:generate:build",enforce:"post",apply:"build",generateBundle(e,t){for(let i in t){let n=t[i];if(n.type!=="asset"||!d(i))continue;let r=n.source,m=r instanceof Uint8Array?new TextDecoder().decode(r):r;m.includes("@tailwind")&&(n.source=p(m))}}}]}export{x as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tailwindcss/vite",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.3",
|
|
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,15 +16,15 @@
|
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@tailwindcss/oxide": "4.0.0-alpha.
|
|
20
|
-
"tailwindcss": "4.0.0-alpha.
|
|
19
|
+
"@tailwindcss/oxide": "4.0.0-alpha.3",
|
|
20
|
+
"tailwindcss": "4.0.0-alpha.3"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@types/node": "^20.11.17",
|
|
24
24
|
"vite": "^5.0.11"
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
|
-
"build": "tsup-node ./src/index.ts --format esm --dts",
|
|
27
|
+
"build": "tsup-node ./src/index.ts --format esm --dts --minify --clean",
|
|
28
28
|
"dev": "pnpm run build -- --watch"
|
|
29
29
|
}
|
|
30
30
|
}
|