@@ -19,7 +19,7 @@ import {
1919} from './constant' ;
2020import {
2121 type CssLoaderOptionsAuto ,
22- RSLIB_TEMP_CSS_DIR ,
22+ RSLIB_CSS_ENTRY_FLAG ,
2323 composeCssConfig ,
2424 cssExternalHandler ,
2525 isCssGlobalFile ,
@@ -686,16 +686,28 @@ const composeEntryConfig = async (
686686 // Using the longest common path of all non-declaration input files by default.
687687 const outBase = lcp === null ? root : lcp ;
688688
689- for ( const file of resolvedEntryFiles ) {
689+ function getEntryName ( file : string ) {
690690 const { dir, name } = path . parse ( path . relative ( outBase , file ) ) ;
691691 // Entry filename contains nested path to preserve source directory structure.
692692 const entryFileName = path . join ( dir , name ) ;
693693
694+ // 1. we mark the global css files (which will generate empty js chunk in cssExtract), and deleteAsset in RemoveCssExtractAssetPlugin
695+ // 2. avoid the same name e.g: `index.ts` and `index.css`
694696 if ( isCssGlobalFile ( file , cssModulesAuto ) ) {
695- resolvedEntries [ `${ RSLIB_TEMP_CSS_DIR } /${ entryFileName } ` ] = file ;
696- } else {
697- resolvedEntries [ entryFileName ] = file ;
697+ return `${ RSLIB_CSS_ENTRY_FLAG } /${ entryFileName } ` ;
698+ }
699+
700+ return entryFileName ;
701+ }
702+
703+ for ( const file of resolvedEntryFiles ) {
704+ const entryName = getEntryName ( file ) ;
705+ if ( resolvedEntries [ entryName ] ) {
706+ logger . warn (
707+ `duplicate entry: ${ entryName } , this may lead to the incorrect output, please rename the file` ,
708+ ) ;
698709 }
710+ resolvedEntries [ entryName ] = file ;
699711 }
700712 }
701713
0 commit comments