Commit 0a89d4de authored by Jacob Schatz's avatar Jacob Schatz

Merge branch 'webpack-autoinclude' into 'master'

Backport of Webpack auto include for EE imports

See merge request gitlab-org/gitlab-ce!17282
parents eb421c88 bb5cf94a
...@@ -29,13 +29,15 @@ var pageEntries = glob.sync('pages/**/index.js', { cwd: path.join(ROOT_PATH, 'ap ...@@ -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 dispatcher = fs.readFileSync(path.join(ROOT_PATH, 'app/assets/javascripts/dispatcher.js')).toString();
var dispatcherChunks = dispatcher.match(/(?!import\(')\.\/pages\/[^']+/g); var dispatcherChunks = dispatcher.match(/(?!import\(')\.\/pages\/[^']+/g);
pageEntries.forEach(( path ) => { function generateAutoEntries(path, prefix = '.') {
let chunkPath = path.replace(/\/index\.js$/, ''); const chunkPath = path.replace(/\/index\.js$/, '');
if (!dispatcherChunks.includes('./' + chunkPath)) { if (!dispatcherChunks.includes(`${prefix}/${chunkPath}`)) {
let chunkName = chunkPath.replace(/\//g, '.'); const chunkName = chunkPath.replace(/\//g, '.');
autoEntries[chunkName] = './' + path; autoEntries[chunkName] = `${prefix}/${path}`;
} }
}); }
pageEntries.forEach(( path ) => generateAutoEntries(path));
// report our auto-generated bundle count // report our auto-generated bundle count
var autoEntriesCount = Object.keys(autoEntries).length; var autoEntriesCount = Object.keys(autoEntries).length;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment