Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Greiling <mike@pixelcog.com>2018-04-27 21:00:00 +0300
committerMike Greiling <mike@pixelcog.com>2018-05-01 23:15:11 +0300
commit94a9c60eb9b557498849f62b136fcdc49e1d406f (patch)
tree0b76a9c219d5875802ea4ed8663a0845fcfc4c35 /config/webpack.config.js
parentd224b59a769de823e868b115b4631e0cd2d8bb09 (diff)
combine ancestor entrypoints into child entrypoints instead of importing bundles for each
Diffstat (limited to 'config/webpack.config.js')
-rw-r--r--config/webpack.config.js20
1 files changed, 18 insertions, 2 deletions
diff --git a/config/webpack.config.js b/config/webpack.config.js
index 4907b328b5a..7ec75f7e5d3 100644
--- a/config/webpack.config.js
+++ b/config/webpack.config.js
@@ -25,6 +25,7 @@ const defaultEntries = ['./webpack', './commons', './main'];
function generateEntries() {
// generate automatic entry points
const autoEntries = {};
+ const autoEntriesMap = {};
const pageEntries = glob.sync('pages/**/index.js', {
cwd: path.join(ROOT_PATH, 'app/assets/javascripts'),
});
@@ -33,14 +34,29 @@ function generateEntries() {
function generateAutoEntries(path, prefix = '.') {
const chunkPath = path.replace(/\/index\.js$/, '');
const chunkName = chunkPath.replace(/\//g, '.');
- autoEntries[chunkName] = defaultEntries.concat(`${prefix}/${path}`);
+ autoEntriesMap[chunkName] = `${prefix}/${path}`;
}
pageEntries.forEach(path => generateAutoEntries(path));
- autoEntriesCount = Object.keys(autoEntries).length;
+ const autoEntryKeys = Object.keys(autoEntriesMap);
+ autoEntriesCount = autoEntryKeys.length;
+
+ // import ancestor entrypoints within their children
+ autoEntryKeys.forEach(entry => {
+ const entryPaths = [autoEntriesMap[entry]];
+ const segments = entry.split('.');
+ while (segments.pop()) {
+ const ancestor = segments.join('.');
+ if (autoEntryKeys.includes(ancestor)) {
+ entryPaths.unshift(autoEntriesMap[ancestor]);
+ }
+ }
+ autoEntries[entry] = defaultEntries.concat(entryPaths);
+ });
const manualEntries = {
+ default: defaultEntries,
raven: './raven/index.js',
ide: './ide/index.js',
};