summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config/webpack.config.js12
-rw-r--r--package.json1
-rw-r--r--yarn.lock2
3 files changed, 14 insertions, 1 deletions
diff --git a/config/webpack.config.js b/config/webpack.config.js
index 783677b5b8d..ed064be690c 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,15 @@ 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') });
+
+pageEntries.forEach(( path ) => {
+ let chunkName = path.replace(/\/index\.js$/, '').replace(/\//g, '.');
+ autoEntries[chunkName] = './' + path;
+});
+
var config = {
// because sqljs requires fs.
node: {
@@ -301,6 +311,8 @@ var config = {
}
}
+config.entry = Object.assign({}, autoEntries, config.entry);
+
if (IS_PRODUCTION) {
config.devtool = 'source-map';
config.plugins.push(
diff --git a/package.json b/package.json
index c68cf648932..df0d2bb3676 100644
--- a/package.json
+++ b/package.json
@@ -47,6 +47,7 @@
"exports-loader": "^0.6.4",
"file-loader": "^0.11.1",
"fuzzaldrin-plus": "^0.5.0",
+ "glob": "^7.1.2",
"imports-loader": "^0.7.1",
"jed": "^1.1.1",
"jquery": "^2.2.4",
diff --git a/yarn.lock b/yarn.lock
index d10a4372a40..e6d5f239d83 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -3322,7 +3322,7 @@ glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.1.1:
once "^1.3.0"
path-is-absolute "^1.0.0"
-glob@^7.1.0, glob@~7.1.2:
+glob@^7.1.0, glob@^7.1.2, glob@~7.1.2:
version "7.1.2"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15"
dependencies: