diff options
author | Clement Ho <ClemMakesApps@gmail.com> | 2018-02-07 12:45:37 -0600 |
---|---|---|
committer | Clement Ho <ClemMakesApps@gmail.com> | 2018-02-07 12:45:37 -0600 |
commit | a0c0ea655a8659bb1388a6ffc6738754c1c0f9bd (patch) | |
tree | bdf8ca27712e033802868fc09533381484f641ae /config/webpack.config.js | |
parent | 48c78958e31c666fcba0b253104d47be5b3c82b0 (diff) | |
parent | 8900b23eab6abd5a6c01278fa0da18d5bed98491 (diff) | |
download | gitlab-ce-axios-profile.tar.gz |
Merge branch 'master' into axios-profileaxios-profile
Diffstat (limited to 'config/webpack.config.js')
-rw-r--r-- | config/webpack.config.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/config/webpack.config.js b/config/webpack.config.js index 783677b5b8d..7f3fe551a03 100644 --- a/config/webpack.config.js +++ b/config/webpack.config.js @@ -3,6 +3,7 @@ var crypto = require('crypto'); var fs = require('fs'); var path = require('path'); +var glob = require('glob'); var webpack = require('webpack'); var StatsWriterPlugin = require('webpack-stats-plugin').StatsWriterPlugin; var CopyWebpackPlugin = require('copy-webpack-plugin'); @@ -20,6 +21,26 @@ var DEV_SERVER_LIVERELOAD = process.env.DEV_SERVER_LIVERELOAD !== 'false'; var WEBPACK_REPORT = process.env.WEBPACK_REPORT; var NO_COMPRESSION = process.env.NO_COMPRESSION; +// generate automatic entry points +var autoEntries = {}; +var pageEntries = glob.sync('pages/**/index.js', { cwd: path.join(ROOT_PATH, 'app/assets/javascripts') }); + +// filter out entries currently imported dynamically in dispatcher.js +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; + } +}); + +// report our auto-generated bundle count +var autoEntriesCount = Object.keys(autoEntries).length; +console.log(`${autoEntriesCount} entries from '/pages' automatically added to webpack output.`); + var config = { // because sqljs requires fs. node: { @@ -301,6 +322,8 @@ var config = { } } +config.entry = Object.assign({}, autoEntries, config.entry); + if (IS_PRODUCTION) { config.devtool = 'source-map'; config.plugins.push( |