@@ -1103,3 +1103,63 @@ test(
11031103 expect ( content ) . toContain ( 'display: flex;' )
11041104 } ,
11051105)
1106+
1107+ test (
1108+ `the plugin works when using the environment API` ,
1109+ {
1110+ fs : {
1111+ 'package.json' : txt `
1112+ {
1113+ "type": "module",
1114+ "dependencies": {
1115+ "@tailwindcss/vite": "workspace:^",
1116+ "tailwindcss": "workspace:^"
1117+ },
1118+ "devDependencies": {
1119+ "vite": "^7"
1120+ }
1121+ }
1122+ ` ,
1123+ 'vite.config.ts' : ts `
1124+ import tailwindcss from '@tailwindcss/vite'
1125+ import { defineConfig } from 'vite'
1126+
1127+ export default defineConfig({
1128+ plugins: [tailwindcss()],
1129+ builder: {},
1130+ environments: {
1131+ server: {
1132+ build: {
1133+ cssMinify: false,
1134+ emitAssets: true,
1135+ rollupOptions: { input: './src/server.ts' },
1136+ },
1137+ },
1138+ },
1139+ })
1140+ ` ,
1141+ // Has to exist or the build fails
1142+ 'index.html' : html `
1143+ <div class="content-['index.html']"></div>
1144+ ` ,
1145+ 'src/server.ts' : js `
1146+ // Import the stylesheet in the server build
1147+ import a from './index.css?url'
1148+ console.log(a)
1149+ ` ,
1150+ 'src/index.css' : css `
1151+ @reference 'tailwindcss/theme';
1152+ @import 'tailwindcss/utilities';
1153+ ` ,
1154+ } ,
1155+ } ,
1156+ async ( { root, fs, exec, expect } ) => {
1157+ await exec ( 'pnpm vite build' , { cwd : root } )
1158+
1159+ let files = await fs . glob ( 'dist/**/*.css' )
1160+ expect ( files ) . toHaveLength ( 1 )
1161+ let [ filename ] = files [ 0 ]
1162+
1163+ await fs . expectFileToContain ( filename , [ candidate `content-['index.html']` ] )
1164+ } ,
1165+ )
0 commit comments