diff options
author | Clement Ho <clemmakesapps@gmail.com> | 2018-02-22 13:15:15 +0000 |
---|---|---|
committer | Jacob Schatz <jschatz@gitlab.com> | 2018-02-22 13:15:15 +0000 |
commit | bb5cf94afd4fe457fad224cd0c452b2228466afe (patch) | |
tree | 691b816def7acffa10a470fa659e5f97de8c328c /config | |
parent | eb421c88ee2a57a437b9b14ba7447a04720354ac (diff) | |
download | gitlab-ce-bb5cf94afd4fe457fad224cd0c452b2228466afe.tar.gz |
Backport of Webpack auto include for EE imports
Diffstat (limited to 'config')
-rw-r--r-- | config/webpack.config.js | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/config/webpack.config.js b/config/webpack.config.js index 06737b34aba..94ff39485fb 100644 --- a/config/webpack.config.js +++ b/config/webpack.config.js @@ -29,13 +29,15 @@ var pageEntries = glob.sync('pages/**/index.js', { cwd: path.join(ROOT_PATH, 'ap var dispatcher = fs.readFileSync(path.join(ROOT_PATH, 'app/assets/javascripts/dispatcher.js')).toString(); var dispatcherChunks = dispatcher.match(/(?!import\(')\.\/pages\/[^']+/g); -pageEntries.forEach(( path ) => { - let chunkPath = path.replace(/\/index\.js$/, ''); - if (!dispatcherChunks.includes('./' + chunkPath)) { - let chunkName = chunkPath.replace(/\//g, '.'); - autoEntries[chunkName] = './' + path; +function generateAutoEntries(path, prefix = '.') { + const chunkPath = path.replace(/\/index\.js$/, ''); + if (!dispatcherChunks.includes(`${prefix}/${chunkPath}`)) { + const chunkName = chunkPath.replace(/\//g, '.'); + autoEntries[chunkName] = `${prefix}/${path}`; } -}); +} + +pageEntries.forEach(( path ) => generateAutoEntries(path)); // report our auto-generated bundle count var autoEntriesCount = Object.keys(autoEntries).length; |