Commit 5a3511ea authored by Mike Greiling's avatar Mike Greiling

prefer let and const in webpack config

parent 6e49a757
'use strict'; 'use strict';
var crypto = require('crypto'); const crypto = require('crypto');
var fs = require('fs'); const fs = require('fs');
var path = require('path'); const path = require('path');
var glob = require('glob'); const glob = require('glob');
var webpack = require('webpack'); const webpack = require('webpack');
var StatsWriterPlugin = require('webpack-stats-plugin').StatsWriterPlugin; const StatsWriterPlugin = require('webpack-stats-plugin').StatsWriterPlugin;
var CopyWebpackPlugin = require('copy-webpack-plugin'); const CopyWebpackPlugin = require('copy-webpack-plugin');
var CompressionPlugin = require('compression-webpack-plugin'); const CompressionPlugin = require('compression-webpack-plugin');
var NameAllModulesPlugin = require('name-all-modules-plugin'); const NameAllModulesPlugin = require('name-all-modules-plugin');
var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
var WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin'); const WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin');
var ROOT_PATH = path.resolve(__dirname, '..'); const ROOT_PATH = path.resolve(__dirname, '..');
var IS_PRODUCTION = process.env.NODE_ENV === 'production'; const IS_PRODUCTION = process.env.NODE_ENV === 'production';
var IS_DEV_SERVER = process.argv.join(' ').indexOf('webpack-dev-server') !== -1; const IS_DEV_SERVER = process.argv.join(' ').indexOf('webpack-dev-server') !== -1;
var DEV_SERVER_HOST = process.env.DEV_SERVER_HOST || 'localhost'; const DEV_SERVER_HOST = process.env.DEV_SERVER_HOST || 'localhost';
var DEV_SERVER_PORT = parseInt(process.env.DEV_SERVER_PORT, 10) || 3808; const DEV_SERVER_PORT = parseInt(process.env.DEV_SERVER_PORT, 10) || 3808;
var DEV_SERVER_LIVERELOAD = process.env.DEV_SERVER_LIVERELOAD !== 'false'; const DEV_SERVER_LIVERELOAD = process.env.DEV_SERVER_LIVERELOAD !== 'false';
var WEBPACK_REPORT = process.env.WEBPACK_REPORT; const WEBPACK_REPORT = process.env.WEBPACK_REPORT;
var NO_COMPRESSION = process.env.NO_COMPRESSION; const NO_COMPRESSION = process.env.NO_COMPRESSION;
var autoEntriesCount = 0; let autoEntriesCount = 0;
var watchAutoEntries = []; let watchAutoEntries = [];
function generateEntries() { function generateEntries() {
// generate automatic entry points // generate automatic entry points
var autoEntries = {}; const autoEntries = {};
var pageEntries = glob.sync('pages/**/index.js', { cwd: path.join(ROOT_PATH, 'app/assets/javascripts') }); const pageEntries = glob.sync('pages/**/index.js', { cwd: path.join(ROOT_PATH, 'app/assets/javascripts') });
watchAutoEntries = [ watchAutoEntries = [
path.join(ROOT_PATH, 'app/assets/javascripts/pages/'), path.join(ROOT_PATH, 'app/assets/javascripts/pages/'),
]; ];
...@@ -74,7 +74,7 @@ function generateEntries() { ...@@ -74,7 +74,7 @@ function generateEntries() {
return Object.assign(manualEntries, autoEntries); return Object.assign(manualEntries, autoEntries);
} }
var config = { const config = {
context: path.join(ROOT_PATH, 'app/assets/javascripts'), context: path.join(ROOT_PATH, 'app/assets/javascripts'),
entry: generateEntries, entry: generateEntries,
...@@ -166,7 +166,7 @@ var config = { ...@@ -166,7 +166,7 @@ var config = {
new StatsWriterPlugin({ new StatsWriterPlugin({
filename: 'manifest.json', filename: 'manifest.json',
transform: function(data, opts) { transform: function(data, opts) {
var stats = opts.compiler.getStats().toJson({ const stats = opts.compiler.getStats().toJson({
chunkModules: false, chunkModules: false,
source: false, source: false,
chunks: false, chunks: false,
......
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