@tailwindcss/vite 0.0.0-insiders.bbc2f3f → 0.0.0-insiders.bc6e4b8
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 +44 -8
- package/dist/index.d.mts +10 -2
- package/dist/index.mjs +1 -1
- package/package.json +8 -9
package/README.md
CHANGED
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
<p align="center">
|
|
16
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
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/
|
|
19
|
-
<a href="https://github.com/
|
|
18
|
+
<a href="https://github.com/tailwindlabs/tailwindcss/releases"><img src="https://img.shields.io/npm/v/tailwindcss.svg" alt="Latest Release"></a>
|
|
19
|
+
<a href="https://github.com/tailwindlabs/tailwindcss/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/tailwindcss.svg" alt="License"></a>
|
|
20
20
|
</p>
|
|
21
21
|
|
|
22
22
|
---
|
|
@@ -27,14 +27,50 @@ For full documentation, visit [tailwindcss.com](https://tailwindcss.com).
|
|
|
27
27
|
|
|
28
28
|
## Community
|
|
29
29
|
|
|
30
|
-
For help, discussion about best practices, or
|
|
30
|
+
For help, discussion about best practices, or feature ideas:
|
|
31
31
|
|
|
32
|
-
[Discuss Tailwind CSS on GitHub](https://github.com/
|
|
32
|
+
[Discuss Tailwind CSS on GitHub](https://github.com/tailwindlabs/tailwindcss/discussions)
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
## Contributing
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
If you're interested in contributing to Tailwind CSS, please read our [contributing docs](https://github.com/tailwindlabs/tailwindcss/blob/main/.github/CONTRIBUTING.md) **before submitting a pull request**.
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## `@tailwindcss/vite` plugin API
|
|
41
|
+
|
|
42
|
+
### Enabling or disabling Lightning CSS
|
|
43
|
+
|
|
44
|
+
By default, this plugin detects whether or not the CSS is being built for production by checking the `NODE_ENV` environment variable. When building for production Lightning CSS will be enabled otherwise it is disabled.
|
|
45
|
+
|
|
46
|
+
If you want to always enable or disable Lightning CSS the `optimize` option may be used:
|
|
47
|
+
|
|
48
|
+
```js
|
|
49
|
+
import tailwindcss from '@tailwindcss/vite'
|
|
50
|
+
import { defineConfig } from 'vite'
|
|
51
|
+
|
|
52
|
+
export default defineConfig({
|
|
53
|
+
plugins: [
|
|
54
|
+
tailwindcss({
|
|
55
|
+
// Disable Lightning CSS optimization
|
|
56
|
+
optimize: false,
|
|
57
|
+
}),
|
|
58
|
+
],
|
|
59
|
+
})
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
It's also possible to keep Lightning CSS enabled but disable minification:
|
|
63
|
+
|
|
64
|
+
```js
|
|
65
|
+
import tailwindcss from '@tailwindcss/vite'
|
|
66
|
+
import { defineConfig } from 'vite'
|
|
39
67
|
|
|
40
|
-
|
|
68
|
+
export default defineConfig({
|
|
69
|
+
plugins: [
|
|
70
|
+
tailwindcss({
|
|
71
|
+
// Enable Lightning CSS but disable minification
|
|
72
|
+
optimize: { minify: false },
|
|
73
|
+
}),
|
|
74
|
+
],
|
|
75
|
+
})
|
|
76
|
+
```
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { Plugin } from 'vite';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
type PluginOptions = {
|
|
4
|
+
/**
|
|
5
|
+
* Optimize and minify the output CSS.
|
|
6
|
+
*/
|
|
7
|
+
optimize?: boolean | {
|
|
8
|
+
minify?: boolean;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
declare function tailwindcss(opts?: PluginOptions): Plugin[];
|
|
4
12
|
|
|
5
|
-
export { tailwindcss as default };
|
|
13
|
+
export { type PluginOptions, tailwindcss as default };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var G=(s,n)=>(n=Symbol[s])?n:Symbol.for("Symbol."+s),V=s=>{throw TypeError(s)};var P=(s,n,e)=>{if(n!=null){typeof n!="object"&&typeof n!="function"&&V("Object expected");var t,d;e&&(t=n[G("asyncDispose")]),t===void 0&&(t=n[G("dispose")],e&&(d=t)),typeof t!="function"&&V("Object not disposable"),d&&(t=function(){try{d.call(this)}catch(c){return Promise.reject(c)}}),s.push([e,t,n])}else e&&s.push([e]);return n},C=(s,n,e)=>{var t=typeof SuppressedError=="function"?SuppressedError:function(l,v,r,o){return o=Error(r),o.name="SuppressedError",o.error=l,o.suppressed=v,o},d=l=>n=e?new t(l,n,"An error was suppressed during disposal"):(e=!0,l),c=l=>{for(;l=s.pop();)try{var v=l[1]&&l[1].call(l[2]);if(l[0])return Promise.resolve(v).then(c,r=>(d(r),c()))}catch(r){d(r)}if(e)throw n};return c()};import{compile as I,env as K,Features as b,Instrumentation as j,normalizePath as J,optimize as N,toSourceMap as T}from"@tailwindcss/node";import{clearRequireCache as k}from"@tailwindcss/node/require-cache";import{Scanner as L}from"@tailwindcss/oxide";import{realpathSync as W}from"fs";import F from"fs/promises";import S from"path";import*as A from"vite";var p=K.DEBUG,M=/[?&](?:worker|sharedworker|raw|url)\b/,D=/\?commonjs-proxy/,E=/[?&]index\=\d+\.css$/;function Y(s={}){let n=[],e=null,t=new x(r=>new Map),d=!1,c=!0,l=!0;function v(r,o){let i,a;if(r){let u=function(m,y){let R=m.createResolver(y),z;return async(w,O,U,_)=>w.name==="client"||w.name==="ssr"?R(O,U,_,w.name==="ssr"):(z??=A.createIdResolver(m,y),z(w,O,U,_))};var f=u;let h=u(r.config,{...r.config.resolve,extensions:[".css"],mainFields:["style"],conditions:["style","development|production"],tryIndex:!1,preferRelative:!0}),g=u(r.config,r.config.resolve);i=(m,y)=>h(r,m,y,!0),a=(m,y)=>g(r,m,y,!0)}else{let u=e.createResolver({...e.resolve,extensions:[".css"],mainFields:["style"],conditions:["style","development|production"],tryIndex:!1,preferRelative:!0}),h=e.createResolver(e.resolve);i=(g,m)=>u(g,m,!0,d),a=(g,m)=>h(g,m,!0,d)}return new B(o,e.root,e?.css.devSourcemap??!1,i,a)}return[{name:"@tailwindcss/vite:scan",enforce:"pre",configureServer(r){n.push(r)},async configResolved(r){e=r,d=e.build.ssr!==!1&&e.build.ssr!==void 0,s.optimize!==void 0&&(c=s.optimize!==!1),l=c&&e.build.cssMinify!==!1,typeof s.optimize=="object"&&(l=s.optimize.minify!==!1)}},{name:"@tailwindcss/vite:generate:serve",apply:"serve",enforce:"pre",transform:{filter:{id:{exclude:[/\/\.vite\//,M,D],include:[/\.css(?:\?.*)?$/,/&lang\.css/,E]}},async handler(r,o){var h=[];try{if(!$(o))return;let i=P(h,new j);p&&i.start("[@tailwindcss/vite] Generate CSS (serve)");let a=t.get(this.environment?.name??"default");let f=a.get(o);f||(f??=v(this.environment??null,o),a.set(o,f));let u=await f.generate(r,R=>this.addWatchFile(R),i);if(!u)return a.delete(o),r;p&&i.end("[@tailwindcss/vite] Generate CSS (serve)");return u}catch(g){var m=g,y=!0}finally{C(h,m,y)}}},hotUpdate({file:r,modules:o,timestamp:i,server:a}){{if(!o.every(u=>u.type==="asset"||u.id===void 0))return;for(let u of new Set([this.environment.name,"client"])){let h=t.get(u);if(h.size===0||!X(r,o,h))continue;let g=new Set;for(let m of o)this.environment.moduleGraph.invalidateModule(m,g,i,!0);return u===this.environment.name?this.environment.hot.send({type:"full-reload"}):a.hot.send?a.hot.send({type:"full-reload"}):a.ws.send&&a.ws.send({type:"full-reload"}),[]}}}},{name:"@tailwindcss/vite:generate:build",apply:"build",enforce:"pre",transform:{filter:{id:{exclude:[/\/\.vite\//,M,D],include:[/\.css(?:\?.*)?$/,/&lang\.css/,E]}},async handler(r,o){var h=[];try{if(!$(o))return;let i=P(h,new j);p&&i.start("[@tailwindcss/vite] Generate CSS (build)");let a=t.get(this.environment?.name??"default");let f=a.get(o);f||(f??=v(this.environment??null,o),a.set(o,f));let u=await f.generate(r,R=>this.addWatchFile(R),i);if(!u)return a.delete(o),r;p&&i.end("[@tailwindcss/vite] Generate CSS (build)");c&&(p&&i.start("[@tailwindcss/vite] Optimize CSS"),u=N(u.code,{minify:l,map:u.map}),p&&i.end("[@tailwindcss/vite] Optimize CSS"));return u}catch(g){var m=g,y=!0}finally{C(h,m,y)}}}}]}function Q(s){let[n]=s.split("?",2);return S.extname(n).slice(1)}function $(s){return s.includes("/.vite/")||M.test(s)||D.test(s)?!1:Q(s)==="css"||s.includes("&lang.css")||s.match(E)}function q(s){return S.resolve(s.replace(/\?.*$/,""))}var x=class extends Map{constructor(e){super();this.factory=e}get(e){let t=super.get(e);return t===void 0&&(t=this.factory(e,this),this.set(e,t)),t}},B=class{constructor(n,e,t,d,c){this.id=n;this.base=e;this.enableSourceMaps=t;this.customCssResolver=d;this.customJsResolver=c}compiler;scanner;candidates=new Set;buildDependencies=new Map;get scannedFiles(){return this.scanner?.files??[]}async generate(n,e,t){let d=q(this.id);function c(i){i!==d&&(/[\#\?].*\.svg$/.test(i)||e(i))}let l=this.requiresBuild(),v=S.dirname(S.resolve(d));if(!this.compiler||!this.scanner||await l){k(Array.from(this.buildDependencies.keys())),this.buildDependencies.clear(),this.addBuildDependency(q(d)),p&&t.start("Setup compiler");let i=[];this.compiler=await I(n,{from:this.enableSourceMaps?this.id:void 0,base:v,shouldRewriteUrls:!0,onDependency:f=>{c(f),i.push(this.addBuildDependency(f))},customCssResolver:this.customCssResolver,customJsResolver:this.customJsResolver}),await Promise.all(i),p&&t.end("Setup compiler"),p&&t.start("Setup scanner");let a=(this.compiler.root==="none"?[]:this.compiler.root===null?[{base:this.base,pattern:"**/*",negated:!1}]:[{...this.compiler.root,negated:!1}]).concat(this.compiler.sources);this.scanner=new L({sources:a}),p&&t.end("Setup scanner")}else for(let i of this.buildDependencies.keys())c(i);if(!(this.compiler.features&(b.AtApply|b.JsPluginCompat|b.ThemeFunction|b.Utilities)))return!1;if(this.compiler.features&b.Utilities){p&&t.start("Scan for candidates");for(let i of this.scanner.scan())this.candidates.add(i);p&&t.end("Scan for candidates")}if(this.compiler.features&b.Utilities){p&&t.start("Register dependency messages");for(let i of this.scanner.files)c(i);for(let i of this.scanner.globs){if(i.pattern[0]==="!")continue;let a=S.relative(this.base,i.base);a[0]!=="."&&(a="./"+a),a=J(a),c(S.posix.join(a,i.pattern));let f=this.compiler.root;if(f!=="none"&&f!==null){let u=J(S.resolve(f.base,f.pattern));if(!await F.stat(u).then(g=>g.isDirectory(),()=>!1))throw new Error(`The path given to \`source(\u2026)\` must be a directory but got \`source(${u})\` instead.`)}}p&&t.end("Register dependency messages")}p&&t.start("Build CSS");let r=this.compiler.build([...this.candidates]);p&&t.end("Build CSS"),p&&t.start("Build Source Map");let o=this.enableSourceMaps?T(this.compiler.buildSourceMap()).raw:void 0;return p&&t.end("Build Source Map"),{code:r,map:o}}async addBuildDependency(n){let e=null;try{e=(await F.stat(n)).mtimeMs}catch{}this.buildDependencies.set(n,e)}async requiresBuild(){for(let[n,e]of this.buildDependencies){if(e===null)return!0;try{if((await F.stat(n)).mtimeMs>e)return!0}catch{return!0}}return!1}};function X(s,n,e){let t=new Set,d=[...n],c={file:s,get realpath(){try{let l=W(s);return Object.defineProperty(c,"realpath",{value:l}),l}catch{return null}}};for(;d.length>0;){let l=d.shift();if(!t.has(l)){if(t.add(l),l.id){let v=e.get(l.id);if(v&&(v.scannedFiles.includes(c.file)||c.realpath&&v.scannedFiles.includes(c.realpath)))return!0}for(let v of l.importers)d.push(v)}}return!1}export{Y as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tailwindcss/vite",
|
|
3
|
-
"version": "0.0.0-insiders.
|
|
3
|
+
"version": "0.0.0-insiders.bc6e4b8",
|
|
4
4
|
"description": "A utility-first CSS framework for rapidly building custom user interfaces.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -20,21 +20,20 @@
|
|
|
20
20
|
"exports": {
|
|
21
21
|
".": {
|
|
22
22
|
"types": "./dist/index.d.mts",
|
|
23
|
-
"
|
|
23
|
+
"default": "./dist/index.mjs"
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"
|
|
28
|
-
"tailwindcss": "0.0.0-insiders.
|
|
29
|
-
"
|
|
30
|
-
"@tailwindcss/oxide": "0.0.0-insiders.bbc2f3f"
|
|
27
|
+
"@tailwindcss/node": "0.0.0-insiders.bc6e4b8",
|
|
28
|
+
"@tailwindcss/oxide": "0.0.0-insiders.bc6e4b8",
|
|
29
|
+
"tailwindcss": "0.0.0-insiders.bc6e4b8"
|
|
31
30
|
},
|
|
32
31
|
"devDependencies": {
|
|
33
|
-
"@types/node": "^20.
|
|
34
|
-
"vite": "^
|
|
32
|
+
"@types/node": "^20.19.0",
|
|
33
|
+
"vite": "^7.3.1"
|
|
35
34
|
},
|
|
36
35
|
"peerDependencies": {
|
|
37
|
-
"vite": "^5.2.0 || ^6"
|
|
36
|
+
"vite": "^5.2.0 || ^6 || ^7"
|
|
38
37
|
},
|
|
39
38
|
"scripts": {
|
|
40
39
|
"build": "tsup-node",
|