Commit 6ddd2f4a authored by Mike Greiling's avatar Mike Greiling

convert config.entry into an function

parent d9b95d9f
...@@ -21,33 +21,29 @@ var DEV_SERVER_LIVERELOAD = process.env.DEV_SERVER_LIVERELOAD !== 'false'; ...@@ -21,33 +21,29 @@ var DEV_SERVER_LIVERELOAD = process.env.DEV_SERVER_LIVERELOAD !== 'false';
var WEBPACK_REPORT = process.env.WEBPACK_REPORT; var WEBPACK_REPORT = process.env.WEBPACK_REPORT;
var NO_COMPRESSION = process.env.NO_COMPRESSION; var NO_COMPRESSION = process.env.NO_COMPRESSION;
// generate automatic entry points function generateEntries() {
var autoEntries = {}; // generate automatic entry points
var pageEntries = glob.sync('pages/**/index.js', { cwd: path.join(ROOT_PATH, 'app/assets/javascripts') }); var autoEntries = {};
var pageEntries = glob.sync('pages/**/index.js', { cwd: path.join(ROOT_PATH, 'app/assets/javascripts') });
function generateAutoEntries(path, prefix = '.') {
const chunkPath = path.replace(/\/index\.js$/, ''); function generateAutoEntries(path, prefix = '.') {
const chunkName = chunkPath.replace(/\//g, '.'); const chunkPath = path.replace(/\/index\.js$/, '');
autoEntries[chunkName] = `${prefix}/${path}`; const chunkName = chunkPath.replace(/\//g, '.');
} autoEntries[chunkName] = `${prefix}/${path}`;
}
pageEntries.forEach(( path ) => generateAutoEntries(path)); pageEntries.forEach(( path ) => generateAutoEntries(path));
// add and replace any ce entries with ee entries const eePageEntries = glob.sync('pages/**/index.js', { cwd: path.join(ROOT_PATH, 'ee/app/assets/javascripts') });
const eePageEntries = glob.sync('pages/**/index.js', { cwd: path.join(ROOT_PATH, 'ee/app/assets/javascripts') }); eePageEntries.forEach(( path ) => generateAutoEntries(path, 'ee'));
eePageEntries.forEach(( path ) => generateAutoEntries(path, 'ee'));
// report our auto-generated bundle count // report our auto-generated bundle count
var autoEntriesCount = Object.keys(autoEntries).length; if (IS_DEV_SERVER) {
console.log(`${autoEntriesCount} entries from '/pages' automatically added to webpack output.`); var autoEntriesCount = Object.keys(autoEntries).length;
console.log(`${autoEntriesCount} entries from '/pages' automatically added to webpack output.`);
}
var config = { const manualEntries = {
// because sqljs requires fs.
node: {
fs: "empty"
},
context: path.join(ROOT_PATH, 'app/assets/javascripts'),
entry: {
balsamiq_viewer: './blob/balsamiq_viewer.js', balsamiq_viewer: './blob/balsamiq_viewer.js',
cycle_analytics: './cycle_analytics/cycle_analytics_bundle.js', cycle_analytics: './cycle_analytics/cycle_analytics_bundle.js',
commit_pipelines: './commit/pipelines/pipelines_bundle.js', commit_pipelines: './commit/pipelines/pipelines_bundle.js',
...@@ -105,7 +101,19 @@ var config = { ...@@ -105,7 +101,19 @@ var config = {
service_desk_issues: 'ee/service_desk_issues/index.js', service_desk_issues: 'ee/service_desk_issues/index.js',
roadmap: 'ee/roadmap', roadmap: 'ee/roadmap',
ee_sidebar: 'ee/sidebar/sidebar_bundle.js', ee_sidebar: 'ee/sidebar/sidebar_bundle.js',
};
return Object.assign(manualEntries, autoEntries);
}
var config = {
// because sqljs requires fs.
node: {
fs: "empty"
}, },
context: path.join(ROOT_PATH, 'app/assets/javascripts'),
entry: generateEntries,
output: { output: {
path: path.join(ROOT_PATH, 'public/assets/webpack'), path: path.join(ROOT_PATH, 'public/assets/webpack'),
...@@ -334,8 +342,6 @@ var config = { ...@@ -334,8 +342,6 @@ var config = {
} }
} }
config.entry = Object.assign({}, autoEntries, config.entry);
if (IS_PRODUCTION) { if (IS_PRODUCTION) {
config.devtool = 'source-map'; config.devtool = 'source-map';
config.plugins.push( config.plugins.push(
......
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