@@ -37,6 +37,24 @@ function registerExtraWebpackFiles(config, _controller) {
3737 } ) ;
3838}
3939
40+ /**
41+ * Simple hash function by bryc
42+ * https://gist.github.com/iperelivskiy/4110988#gistcomment-2697447
43+ */
44+ function hash ( s ) {
45+ let h = 0xdeadbeef ;
46+ for ( let i = 0 ; i < s . length ; i ++ ) {
47+ h = Math . imul ( h ^ s . charCodeAt ( i ) , 2654435761 ) ; // eslint-disable-line no-bitwise
48+ }
49+ return ( h ^ ( h >>> 16 ) ) >>> 0 ; // eslint-disable-line no-bitwise
50+ }
51+
52+ function getPathKey ( filePath , withExtension = false ) {
53+ const pathParts = path . parse ( filePath ) ;
54+ const key = `${ pathParts . name } .${ hash ( filePath ) } ` ;
55+ return withExtension ? `${ key } ${ pathParts . ext } ` : key ;
56+ }
57+
4058function configToWebpackEntries ( config ) {
4159 const filteredPreprocessorsPatterns = [ ] ;
4260 const { preprocessors } = config ;
@@ -65,7 +83,7 @@ function configToWebpackEntries(config) {
6583
6684 const webpackEntries = { } ;
6785 filteredFiles . forEach ( ( filePath ) => {
68- webpackEntries [ path . parse ( filePath ) . name ] = filePath ;
86+ webpackEntries [ getPathKey ( filePath ) ] = filePath ;
6987 } ) ;
7088
7189 return webpackEntries ;
@@ -97,7 +115,8 @@ function preprocessorFactory(config, emitter) {
97115
98116 file . path = normalize ( transformPath ( file . path ) ) ; // eslint-disable-line no-param-reassign
99117
100- const bundleContent = controller . bundlesContent [ path . parse ( file . path ) . base ] ;
118+ const bundleContent =
119+ controller . bundlesContent [ getPathKey ( file . path , true ) ] ;
101120 done ( null , bundleContent ) ;
102121 } ;
103122}
0 commit comments