@@ -27,6 +27,10 @@ function fixWindowsPath(path) {
2727 return path . replace ( / ^ [ ^ : ] + : \\ / , '\\' ) . replaceAll ( '\\' , '/' )
2828}
2929
30+ const srcDir = fixWindowsPath ( fileURLToPath ( new URL ( '../src' , import . meta. url ) ) ) ;
31+ const libDir = fixWindowsPath ( fileURLToPath ( new URL ( '../lib' , import . meta. url ) ) ) ;
32+ const labsDir = fixWindowsPath ( fileURLToPath ( new URL ( '../src/labs' , import . meta. url ) ) ) ;
33+
3034export default [
3135 {
3236 input : 'src/entry-bundler.ts' ,
@@ -85,11 +89,9 @@ export default [
8589 } )
8690
8791 // Individual CSS files
88- for ( const { id, content } of styleNodes ) {
89- const out = path . parse ( fixWindowsPath ( id ) . replace (
90- fileURLToPath ( new URL ( '../src' , import . meta. url ) ) ,
91- fileURLToPath ( new URL ( '../lib' , import . meta. url ) )
92- ) )
92+ for ( const { id, content} of styleNodes ) {
93+ const relativePath = path . relative ( srcDir , fixWindowsPath ( id ) )
94+ const out = path . parse ( path . join ( libDir , relativePath ) )
9395 mkdirp ( out . dir ) . then ( ( ) => {
9496 writeFile ( path . join ( out . dir , out . name + '.css' ) , content , 'utf8' )
9597 } )
@@ -222,12 +224,13 @@ export default [
222224 } )
223225
224226 // Individual CSS files
225- styleNodes = styleNodes . filter ( node => node . id . includes ( 'src/labs' ) )
227+ styleNodes = styleNodes . filter ( node => {
228+ return fixWindowsPath ( node . id ) . startsWith ( labsDir )
229+ }
230+ ) ;
226231 for ( const { id, content } of styleNodes ) {
227- const out = path . parse ( fixWindowsPath ( id ) . replace (
228- fileURLToPath ( new URL ( '../src' , import . meta. url ) ) ,
229- fileURLToPath ( new URL ( '../lib' , import . meta. url ) )
230- ) )
232+ const relativePath = path . relative ( srcDir , fixWindowsPath ( id ) )
233+ const out = path . parse ( path . join ( libDir , relativePath ) )
231234 mkdirp ( out . dir ) . then ( ( ) => {
232235 writeFile ( path . join ( out . dir , out . name + '.css' ) , content , 'utf8' )
233236 } )
0 commit comments