@@ -37,6 +37,24 @@ function registerExtraWebpackFiles(config, _controller) {
37
37
} ) ;
38
38
}
39
39
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
+
40
58
function configToWebpackEntries ( config ) {
41
59
const filteredPreprocessorsPatterns = [ ] ;
42
60
const { preprocessors } = config ;
@@ -65,7 +83,7 @@ function configToWebpackEntries(config) {
65
83
66
84
const webpackEntries = { } ;
67
85
filteredFiles . forEach ( ( filePath ) => {
68
- webpackEntries [ path . parse ( filePath ) . name ] = filePath ;
86
+ webpackEntries [ getPathKey ( filePath ) ] = filePath ;
69
87
} ) ;
70
88
71
89
return webpackEntries ;
@@ -97,7 +115,8 @@ function preprocessorFactory(config, emitter) {
97
115
98
116
file . path = normalize ( transformPath ( file . path ) ) ; // eslint-disable-line no-param-reassign
99
117
100
- const bundleContent = controller . bundlesContent [ path . parse ( file . path ) . base ] ;
118
+ const bundleContent =
119
+ controller . bundlesContent [ getPathKey ( file . path , true ) ] ;
101
120
done ( null , bundleContent ) ;
102
121
} ;
103
122
}
0 commit comments