@@ -730,6 +730,86 @@ describe.each(['postcss', 'lightningcss'])('%s', (transformer) => {
730730 expect ( files ) . toHaveLength ( 0 )
731731 } ,
732732 )
733+
734+ test (
735+ 'source(…) and `@source` are relative to the file they are in' ,
736+ {
737+ fs : {
738+ 'package.json' : json `
739+ {
740+ "type" : "module" ,
741+ "dependencies" : {
742+ "@tailwindcss/vite" : "workspace:^" ,
743+ "tailwindcss" : "workspace:^"
744+ },
745+ "devDependencies" : {
746+ ${ transformer === 'lightningcss' ? `"lightningcss": "^1",` : '' }
747+ "vite" : "^7"
748+ }
749+ }
750+ ` ,
751+ 'vite.config.ts' : ts `
752+ impor t tailwindcss from '@tailwindcss/vite'
753+ import { defineConfig } from 'vite'
754+
755+ export default defineConfig ({
756+ css: ${ transformer === 'postcss' ? '{}' : "{ transformer: 'lightningcss' }" } ,
757+ build: { cssMinify: false },
758+ plugins: [tailwindcss ()],
759+ })
760+ ` ,
761+ 'index.html' : html `
762+ <head>
763+ <link rel= "stylesheet" href = "/index.css" / >
764+ </ head>
765+ <body> </ body>
766+ ` ,
767+ 'index.css' : css ` @import './project-a/src/index.css' ; ` ,
768+
769+ 'project-a/src/index.css' : css `
770+ /* Run auto-content detection in ../../project-b */
771+ @import 'tailwindcss/utilities' source ('../../project-b' );
772+
773+ /* Explicitly using node_modules in the @source allows git ignored folders */
774+ @source '../../project-c' ;
775+ ` ,
776+
777+ // Project A is the current folder, but we explicitly configured
778+ // `source(project-b)`, therefore project-a should not be included in
779+ // the output.
780+ 'project-a/src/index.html' : html `
781+ <div
782+ class= "content-['SHOULD-NOT-EXIST-IN-OUTPUT'] content-['project-a/src/index.html']"
783+ > </ div>
784+ ` ,
785+
786+ // Project B is the configured `source(…)`, therefore auto source
787+ // detection should include known extensions and folders in the output.
788+ 'project-b/src/index.html' : html `
789+ <div
790+ class= "content-['project-b/src/index.html']"
791+ > </ div>
792+ ` ,
793+
794+ // Project C should apply auto source detection, therefore known
795+ // extensions and folders should be included in the output.
796+ 'project-c/src/index.html' : html `
797+ <div
798+ class= "content-['project-c/src/index.html']"
799+ > </ div>
800+ ` ,
801+ } ,
802+ } ,
803+ async ( { fs, exec, spawn, root, expect } ) => {
804+ await exec ( 'pnpm vite build' , { cwd : root } )
805+
806+ let content = await fs . dumpFiles ( './dist/assets/*.css' )
807+
808+ expect ( content ) . not . toContain ( candidate `content- ['project-a/src/index.html' ]` )
809+ expect ( content ) . toContain ( candidate `content- ['project-b/src/index.html' ]` )
810+ expect ( content ) . toContain ( candidate `content- ['project-c/src/index.html' ]` )
811+ } ,
812+ )
733813} )
734814
735815test (
0 commit comments