From 45b31f0227a4bbba17c786e8766d38a45ee493cc Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 29 Mar 2016 14:11:12 +0200 Subject: [PATCH] Fixed singleton loading problems from webpack config. --- CHANGELOG.md | 3 ++- webpack.config.js | 13 +++---------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 82a19aa..d05ede7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## 1.5.3: 1. Asset paths are now relative (makes it easier to use bundles in subdirectories) +2. Removed loading problems for webpack configurations overriding (see https://github.com/newtriks/generator-react-webpack/issues/194) ## 1.5.2: @@ -10,7 +11,7 @@ ## 1.5.1: -1. Emergency fix for corruct eslint version (2.3 is currently buggy). Fixes https://github.com/newtriks/generator-react-webpack/issues/196 +1. Emergency fix for correct eslint version (2.3 is currently buggy). Fixes https://github.com/newtriks/generator-react-webpack/issues/196 2. Added mocha to eslint global config as requested in https://github.com/newtriks/generator-react-webpack/issues/195 ## 1.5.0: diff --git a/webpack.config.js b/webpack.config.js index 7248ca2..ccb94c6 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -8,7 +8,7 @@ const allowedEnvs = ['dev', 'dist', 'test']; // Set the correct environment var env; -if(args._.length > 0 && args._.indexOf('start') !== -1) { +if (args._.length > 0 && args._.indexOf('start') !== -1) { env = 'test'; } else if (args.env) { env = args.env; @@ -17,14 +17,6 @@ if(args._.length > 0 && args._.indexOf('start') !== -1) { } process.env.REACT_WEBPACK_ENV = env; -// Get available configurations -const configs = { - base: require(path.join(__dirname, 'cfg/base')), - dev: require(path.join(__dirname, 'cfg/dev')), - dist: require(path.join(__dirname, 'cfg/dist')), - test: require(path.join(__dirname, 'cfg/test')) -}; - /** * Build the webpack configuration * @param {String} wantedEnv The wanted environment @@ -33,7 +25,8 @@ const configs = { function buildConfig(wantedEnv) { let isValid = wantedEnv && wantedEnv.length > 0 && allowedEnvs.indexOf(wantedEnv) !== -1; let validEnv = isValid ? wantedEnv : 'dev'; - return configs[validEnv]; + let config = require(path.join(__dirname, 'cfg/' + validEnv)); + return config; } module.exports = buildConfig(env);