Commit bb5cf94a authored by Clement Ho's avatar Clement Ho Committed by Jacob Schatz

Backport of Webpack auto include for EE imports

parent eb421c88
...@@ -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