@tailwindcss/vite 0.0.0-insiders.d38554d → 0.0.0-insiders.d520e1f

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 CHANGED
@@ -13,10 +13,10 @@
13
13
  </p>
14
14
 
15
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>
16
+ <a href="https://github.com/tailwindlabs/tailwindcss/actions"><img src="https://img.shields.io/github/actions/workflow/status/tailwindlabs/tailwindcss/ci.yml?branch=main" 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/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>
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 any other conversation that would benefit from being searchable:
30
+ For help, discussion about best practices, or feature ideas:
31
31
 
32
- [Discuss Tailwind CSS on GitHub](https://github.com/tailwindcss/tailwindcss/discussions)
32
+ [Discuss Tailwind CSS on GitHub](https://github.com/tailwindlabs/tailwindcss/discussions)
33
33
 
34
- For chatting with others using the framework:
34
+ ## Contributing
35
35
 
36
- [Join the Tailwind CSS Discord Server](https://discord.gg/7NF8GNe)
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
- ## Contributing
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
- 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**.
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
- declare function tailwindcss(): Plugin[];
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 C=(r,e)=>(e=Symbol[r])?e:Symbol.for("Symbol."+r),D=r=>{throw TypeError(r)};var b=(r,e,s)=>{if(e!=null){typeof e!="object"&&typeof e!="function"&&D("Object expected");var i,o;s&&(i=e[C("asyncDispose")]),i===void 0&&(i=e[C("dispose")],s&&(o=i)),typeof i!="function"&&D("Object not disposable"),o&&(i=function(){try{o.call(this)}catch(n){return Promise.reject(n)}}),r.push([s,i,e])}else s&&r.push([s]);return e},S=(r,e,s)=>{var i=typeof SuppressedError=="function"?SuppressedError:function(a,d,u,t){return t=Error(u),t.name="SuppressedError",t.error=a,t.suppressed=d,t},o=a=>e=s?new i(a,e,"An error was suppressed during disposal"):(s=!0,a),n=a=>{for(;a=r.pop();)try{var d=a[1]&&a[1].call(a[2]);if(a[0])return Promise.resolve(d).then(n,u=>(o(u),n()))}catch(u){o(u)}if(s)throw e};return n()};import{compile as M,env as _,Features as v,Instrumentation as P,normalizePath as B,optimize as U}from"@tailwindcss/node";import{clearRequireCache as V}from"@tailwindcss/node/require-cache";import{Scanner as G}from"@tailwindcss/oxide";import w from"node:fs/promises";import p from"node:path";var f=_.DEBUG,J=/[?&](?:worker|sharedworker|raw|url)\b/,A=/\?commonjs-proxy/,K=/[?&]index\=\d+\.css$/;function O(){let r=[],e=null,s=!1,i=!1,o=new y(n=>{let a=e.createResolver({...e.resolve,extensions:[".css"],mainFields:["style"],conditions:["style","development|production"],tryIndex:!1,preferRelative:!0});function d(l,c){return a(l,c,!0,s)}let u=e.createResolver(e.resolve);function t(l,c){return u(l,c,!0,s)}return new R(n,e.root,d,t)});return[{name:"@tailwindcss/vite:scan",enforce:"pre",configureServer(n){r.push(n)},async configResolved(n){e=n,i=e.build.cssMinify!==!1,s=e.build.ssr!==!1&&e.build.ssr!==void 0}},{name:"@tailwindcss/vite:generate:serve",apply:"serve",enforce:"pre",async transform(n,a,d){var c=[];try{if(!x(a))return;let u=b(c,new P);f&&u.start("[@tailwindcss/vite] Generate CSS (serve)");let t=o.get(a);let l=await t.generate(n,F=>this.addWatchFile(F),u);if(!l)return o.delete(a),n;f&&u.end("[@tailwindcss/vite] Generate CSS (serve)");return{code:l}}catch(m){var g=m,h=!0}finally{S(c,g,h)}}},{name:"@tailwindcss/vite:generate:build",apply:"build",enforce:"pre",async transform(n,a){var l=[];try{if(!x(a))return;let d=b(l,new P);f&&d.start("[@tailwindcss/vite] Generate CSS (build)");let u=o.get(a);let t=await u.generate(n,h=>this.addWatchFile(h),d);if(!t)return o.delete(a),n;f&&d.end("[@tailwindcss/vite] Generate CSS (build)");f&&d.start("[@tailwindcss/vite] Optimize CSS");t=U(t,{minify:i});f&&d.end("[@tailwindcss/vite] Optimize CSS");return{code:t}}catch(c){var m=c,g=!0}finally{S(l,m,g)}}}]}function T(r){let[e]=r.split("?",2);return p.extname(e).slice(1)}function x(r){return r.includes("/.vite/")?void 0:(T(r)==="css"||r.includes("&lang.css")||r.match(K))&&!J.test(r)&&!A.test(r)}function E(r){return p.resolve(r.replace(/\?.*$/,""))}var y=class extends Map{constructor(s){super();this.factory=s}get(s){let i=super.get(s);return i===void 0&&(i=this.factory(s,this),this.set(s,i)),i}},R=class{constructor(e,s,i,o){this.id=e;this.base=s;this.customCssResolver=i;this.customJsResolver=o}compiler;scanner;candidates=new Set;buildDependencies=new Map;async generate(e,s,i){let o=E(this.id);function n(t){t!==o&&(/[\#\?].*\.svg$/.test(t)||s(t))}let a=this.requiresBuild(),d=p.dirname(p.resolve(o));if(!this.compiler||!this.scanner||await a){V(Array.from(this.buildDependencies.keys())),this.buildDependencies.clear(),this.addBuildDependency(E(o)),f&&i.start("Setup compiler");let t=[];this.compiler=await M(e,{base:d,shouldRewriteUrls:!0,onDependency:c=>{n(c),t.push(this.addBuildDependency(c))},customCssResolver:this.customCssResolver,customJsResolver:this.customJsResolver}),await Promise.all(t),f&&i.end("Setup compiler"),f&&i.start("Setup scanner");let l=(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 G({sources:l}),f&&i.end("Setup scanner")}else for(let t of this.buildDependencies.keys())n(t);if(!(this.compiler.features&(v.AtApply|v.JsPluginCompat|v.ThemeFunction|v.Utilities)))return!1;if(this.compiler.features&v.Utilities){f&&i.start("Scan for candidates");for(let t of this.scanner.scan())this.candidates.add(t);f&&i.end("Scan for candidates")}if(this.compiler.features&v.Utilities){for(let t of this.scanner.files)n(t);for(let t of this.scanner.globs){if(t.pattern[0]==="!")continue;let l=p.relative(this.base,t.base);l[0]!=="."&&(l="./"+l),l=B(l),n(p.posix.join(l,t.pattern));let c=this.compiler.root;if(c!=="none"&&c!==null){let m=B(p.resolve(c.base,c.pattern));if(!await w.stat(m).then(h=>h.isDirectory(),()=>!1))throw new Error(`The path given to \`source(\u2026)\` must be a directory but got \`source(${m})\` instead.`)}}}f&&i.start("Build CSS");let u=this.compiler.build([...this.candidates]);return f&&i.end("Build CSS"),u}async addBuildDependency(e){let s=null;try{s=(await w.stat(e)).mtimeMs}catch{}this.buildDependencies.set(e,s)}async requiresBuild(){for(let[e,s]of this.buildDependencies){if(s===null)return!0;try{if((await w.stat(e)).mtimeMs>s)return!0}catch{return!0}}return!1}};export{O as default};
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.d38554d",
3
+ "version": "0.0.0-insiders.d520e1f",
4
4
  "description": "A utility-first CSS framework for rapidly building custom user interfaces.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -20,20 +20,20 @@
20
20
  "exports": {
21
21
  ".": {
22
22
  "types": "./dist/index.d.mts",
23
- "import": "./dist/index.mjs"
23
+ "default": "./dist/index.mjs"
24
24
  }
25
25
  },
26
26
  "dependencies": {
27
- "@tailwindcss/node": "0.0.0-insiders.d38554d",
28
- "tailwindcss": "0.0.0-insiders.d38554d",
29
- "@tailwindcss/oxide": "0.0.0-insiders.d38554d"
27
+ "tailwindcss": "0.0.0-insiders.d520e1f",
28
+ "@tailwindcss/oxide": "0.0.0-insiders.d520e1f",
29
+ "@tailwindcss/node": "0.0.0-insiders.d520e1f"
30
30
  },
31
31
  "devDependencies": {
32
- "@types/node": "^20.14.8",
33
- "vite": "^6.0.0"
32
+ "@types/node": "^20.19.0",
33
+ "vite": "^7.3.1"
34
34
  },
35
35
  "peerDependencies": {
36
- "vite": "^5.2.0 || ^6"
36
+ "vite": "^5.2.0 || ^6 || ^7"
37
37
  },
38
38
  "scripts": {
39
39
  "build": "tsup-node",