jormungandr-bite/webpack/plugins/index.ts
syuilo 986c53a8d0 ✌️
2018-02-25 15:50:25 +09:00

32 lines
752 B
TypeScript

import * as webpack from 'webpack';
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
import chalk from 'chalk';
import consts from './consts';
import hoist from './hoist';
import minify from './minify';
const env = process.env.NODE_ENV;
const isProduction = env === 'production';
export default (version, lang) => {
const plugins = [
new ProgressBarPlugin({
format: chalk` {cyan.bold yes we can} {bold [}:bar{bold ]} {green.bold :percent} {gray (:current/:total)} :elapseds`,
clear: false
}),
consts(lang),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(process.env.NODE_ENV)
}
})
];
if (isProduction) {
plugins.push(hoist());
plugins.push(minify());
}
return plugins;
};