@@ -141,6 +141,8 @@ export const pluginOutput = (): RsbuildPlugin => ({
141141
142142 const cssPath = config . output . distPath . css ;
143143 const cssFilename = getFilename ( config , 'css' , isProd ) ;
144+ const isCssFilenameFn = typeof cssFilename === 'function' ;
145+
144146 const cssAsyncPath =
145147 config . output . distPath . cssAsync ??
146148 ( cssPath ? `${ cssPath } /async` : 'async' ) ;
@@ -149,8 +151,18 @@ export const pluginOutput = (): RsbuildPlugin => ({
149151 . plugin ( CHAIN_ID . PLUGIN . MINI_CSS_EXTRACT )
150152 . use ( getCssExtractPlugin ( ) , [
151153 {
152- filename : posix . join ( cssPath , cssFilename ) ,
153- chunkFilename : posix . join ( cssAsyncPath , cssFilename ) ,
154+ filename : isCssFilenameFn
155+ ? ( ...args ) => {
156+ const name = cssFilename ( ...args ) ;
157+ return posix . join ( cssPath , name ) ;
158+ }
159+ : posix . join ( cssPath , cssFilename ) ,
160+ chunkFilename : isCssFilenameFn
161+ ? ( ...args ) => {
162+ const name = cssFilename ( ...args ) ;
163+ return posix . join ( cssAsyncPath , name ) ;
164+ }
165+ : posix . join ( cssAsyncPath , cssFilename ) ,
154166 ...extractPluginOptions ,
155167 } ,
156168 ] ) ;
0 commit comments