Skip to content
Snippets Groups Projects
Verified Commit 90012481 authored by Mike Greiling's avatar Mike Greiling
Browse files

generate webpack entry points for pages directory automatically

parent a24e5827
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -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');
Loading
Loading
@@ -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: {
Loading
Loading
@@ -301,6 +311,8 @@ var config = {
}
}
 
config.entry = Object.assign({}, autoEntries, config.entry);
if (IS_PRODUCTION) {
config.devtool = 'source-map';
config.plugins.push(
Loading
Loading
Loading
Loading
@@ -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",
Loading
Loading
Loading
Loading
@@ -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:
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment