@@ -27,14 +27,17 @@ function loadStylesheet(id: string, base: string) {
2727 return { path : file , base : path . dirname ( file ) , content : readFileSync ( file , "utf8" ) } ;
2828}
2929
30- async function build ( entry : string , candidates : string [ ] ) : Promise < string > {
31- const compiled = await compile ( readFileSync ( path . join ( STYLES_DIR , entry ) , "utf8" ) , {
30+ async function buildSource ( source : string , candidates : string [ ] ) : Promise < string > {
31+ const compiled = await compile ( source , {
3232 base : STYLES_DIR ,
3333 loadStylesheet,
3434 } ) ;
3535 return compiled . build ( candidates ) ;
3636}
3737
38+ const build = ( entry : string , candidates : string [ ] ) =>
39+ buildSource ( readFileSync ( path . join ( STYLES_DIR , entry ) , "utf8" ) , candidates ) ;
40+
3841function rootVariables ( css : string ) : Map < string , string > {
3942 const block = css . match ( / : r o o t , : h o s t \{ ( [ \s \S ] * ?) \n { 2 } \} / ) ;
4043 const vars = new Map < string , string > ( ) ;
@@ -74,7 +77,7 @@ describe("studio theme", () => {
7477 } ) ;
7578
7679 it ( "drops every Tailwind default color Studio does not use" , async ( ) => {
77- // `--color-*: initial ` clears the stock palette. The entries Studio's
80+ // `palette-reset.css ` clears the stock palette. The entries Studio's
7881 // markup still references are re-declared as deprecated aliases (U12
7982 // removes them); anything outside that set must no longer resolve.
8083 const css = await build ( "studio.css" , [ "bg-neutral-750" , "text-teal-500" , "bg-neutral-800" ] ) ;
@@ -84,6 +87,16 @@ describe("studio theme", () => {
8487 expect ( css ) . toContain ( ".bg-neutral-800 {" ) ;
8588 } ) ;
8689
90+ it ( "leaves a host's stock Tailwind colors alone when only theme.css is imported" , async ( ) => {
91+ const css = await buildSource ( '@import "tailwindcss";\n@import "./theme.css";' , [
92+ "bg-teal-500" ,
93+ "text-accent" ,
94+ ] ) ;
95+
96+ expect ( css ) . toContain ( ".bg-teal-500 {" ) ;
97+ expect ( css ) . toContain ( ".text-accent {" ) ;
98+ } ) ;
99+
87100 it ( "keeps selection, playhead and accent as three distinct colors" , ( ) => {
88101 const accent = declaredValue ( "--color-accent" ) ;
89102 const selection = declaredValue ( "--color-selection" ) ;
0 commit comments