@@ -30,12 +30,11 @@ export interface BuildShadowCssOptions {
3030 */
3131 primaryRampPath : string
3232 /**
33- * Absolute path to a hand-authored stylesheet run through the generator's
34- * configured transformers (directives, variant groups) and merged in
35- * right after the CSS reset. Omit for a package with no hand-written
36- * styles.
33+ * Absolute paths to hand-authored stylesheets run through the generator's
34+ * configured transformers (directives, variant groups) and merged in order
35+ * right after the CSS reset. Omit for a package with no hand-written styles.
3736 */
38- userStylePath ?: string
37+ userStylePaths ?: string [ ]
3938 /**
4039 * Prefix Wind's `--un-*` custom properties are renamed to (see
4140 * `namespaceShadowCssVars`) — unique per shadow-root surface so two
@@ -61,7 +60,7 @@ export interface BuildShadowCssResult {
6160// generated file itself; returns stats so each caller (a `scripts/` entry,
6261// exempt from the `no-console` lint rule) prints its own summary line.
6362export async function buildShadowCss ( options : BuildShadowCssOptions ) : Promise < BuildShadowCssResult > {
64- const { srcDir, globs, config, primaryRampPath, userStylePath , varPrefix } = options
63+ const { srcDir, globs, config, primaryRampPath, userStylePaths , varPrefix } = options
6564 const generatedCss = join ( srcDir , '.generated/css.ts' )
6665
6766 const require = createRequire ( import . meta. url )
@@ -93,15 +92,15 @@ export async function buildShadowCss(options: BuildShadowCssOptions): Promise<Bu
9392 await generator . applyExtractors ( content , file , tokens )
9493 }
9594
96- // The hand -written stylesheet (if any) may use `--at-apply` — run it
97- // through the configured transformers (directives, variant groups) before
98- // merging.
99- const userStyle = userStylePath
100- ? new MagicString ( await fs . readFile ( userStylePath , 'utf-8' ) . catch ( ( ) => '' ) )
101- : undefined
102- if ( userStyle ) {
95+ // Hand -written stylesheets may use `--at-apply`. Run each through the
96+ // configured transformers before merging them in the caller's order.
97+ const userStyles = await Promise . all ( ( userStylePaths ?? [ ] ) . map ( async userStylePath => ( {
98+ path : userStylePath ,
99+ source : new MagicString ( await fs . readFile ( userStylePath , 'utf-8' ) . catch ( ( ) => '' ) ) ,
100+ } ) ) )
101+ for ( const userStyle of userStyles ) {
103102 for ( const transformer of generator . config . transformers ?? [ ] ) {
104- await transformer . transform ( userStyle , userStylePath ! , { uno : generator } as any )
103+ await transformer . transform ( userStyle . source , userStyle . path , { uno : generator } as any )
105104 }
106105 }
107106
@@ -126,7 +125,7 @@ export async function buildShadowCss(options: BuildShadowCssOptions): Promise<Bu
126125 // `namespaceShadowCssVars`).
127126 let css = [
128127 reset ,
129- userStyle ?. toString ( ) ,
128+ ... userStyles . map ( userStyle => userStyle . source . toString ( ) ) ,
130129 unoCss ,
131130 surfacesCss ,
132131 primaryRamp ,
0 commit comments