This commit is contained in:
syuilo 2018-03-18 17:21:58 +09:00
parent f1dc3ebddd
commit 40c531259d

View file

@ -21,9 +21,6 @@ import locales from './locales';
const meta = require('./package.json'); const meta = require('./package.json');
const version = meta.version; const version = meta.version;
const env = process.env.NODE_ENV || 'development';
const isProduction = env === 'production';
//#region Replacer definitions //#region Replacer definitions
global['faReplacement'] = faReplacement; global['faReplacement'] = faReplacement;
@ -42,12 +39,12 @@ global['base64replacement'] = (_, key) => {
const langs = Object.keys(locales); const langs = Object.keys(locales);
const entries = isProduction const entries = process.env.NODE_ENV == 'production'
? langs.map(l => [l, false]).concat(langs.map(l => [l, true])) ? langs.map(l => [l, false]).concat(langs.map(l => [l, true]))
: [['ja', false]]; : [['ja', false]];
module.exports = entries.map(x => { module.exports = entries.map(x => {
const [lang, shouldOptimize] = x; const [lang, isProduction] = x;
// Chunk name // Chunk name
const name = lang; const name = lang;
@ -66,7 +63,7 @@ module.exports = entries.map(x => {
const output = { const output = {
path: __dirname + '/built/web/assets', path: __dirname + '/built/web/assets',
filename: `[name].${version}.${lang}.${shouldOptimize ? 'min' : 'raw'}.js` filename: `[name].${version}.${lang}.${isProduction ? 'min' : 'raw'}.js`
}; };
const i18nReplacer = new I18nReplacer(lang as string); const i18nReplacer = new I18nReplacer(lang as string);
@ -107,7 +104,7 @@ module.exports = entries.map(x => {
}), }),
new webpack.DefinePlugin(_consts), new webpack.DefinePlugin(_consts),
new webpack.DefinePlugin({ new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV) 'process.env.NODE_ENV': JSON.stringify(isProduction ? 'production' : 'development')
}), }),
new WebpackOnBuildPlugin(stats => { new WebpackOnBuildPlugin(stats => {
fs.writeFileSync('./version.json', JSON.stringify({ fs.writeFileSync('./version.json', JSON.stringify({
@ -116,7 +113,7 @@ module.exports = entries.map(x => {
}) })
]; ];
if (shouldOptimize) { if (isProduction) {
plugins.push(new webpack.optimize.ModuleConcatenationPlugin()); plugins.push(new webpack.optimize.ModuleConcatenationPlugin());
} }
@ -241,13 +238,6 @@ module.exports = entries.map(x => {
}, },
cache: true, cache: true,
devtool: false, //'source-map', devtool: false, //'source-map',
optimization: { mode: isProduction ? 'production' : 'development'
minimize: isProduction && shouldOptimize
},
mode: isProduction
? shouldOptimize
? 'production'
: 'development'
: 'development'
}; };
}); });