redux-scc/webpack.config.js

71 lines
2.0 KiB
JavaScript
Raw Normal View History

2016-09-21 00:58:31 +08:00
const webpack = require('webpack');
const path = require('path');
const PATH_ESLINT = path.join(__dirname, '.eslintrc.js');
const PATH_SRC = path.join(__dirname, 'src');
2016-09-21 00:58:31 +08:00
2016-09-21 15:00:38 +08:00
const isProd = process.argv.indexOf('--prod') >= 0;
const envPlugins = isProd ? [
new webpack.optimize.OccurrenceOrderPlugin(true),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin({
compress: { warnings: false, unused: true, dead_code: true },
output: { comments: false }
}),
] : [];
const envOptions = isProd ? {} : { devtool: 'inline-source-map' };
module.exports = Object.assign(envOptions, {
2016-09-21 00:58:31 +08:00
context: __dirname,
entry: {
'shell-game': PATH_SRC
2016-09-21 00:58:31 +08:00
},
devServer: {
inline: true,
},
output: {
path: path.join(__dirname, 'dist'),
filename: '[name].bundle.js',
},
eslint: {
configFile: PATH_ESLINT,
},
module: {
loaders: [
{
test: /\.(js|jsx)$/,
include: [PATH_SRC],
exclude: [],
loader: "babel-loader",
},
{
test: /\.css$/,
loaders: ['style', 'css', 'sass']
},
{
test: /\.scss$/,
loaders: [
'style',
'css?modules&importLoaders=1&localIdentName=[path]___[name]__[local]___[hash:base64:5]',
'sass'
]
}
],
preLoaders: [ { test: /\.js$/, include: [PATH_SRC], loader: 'eslint-loader' } ]
},
resolve: {
extensions: ['', '.js', '.json', '.jsx'],
alias: [
{ 'shell-game': PATH_SRC }
],
2016-09-21 00:58:31 +08:00
},
plugins: [
2016-09-21 15:00:38 +08:00
...envPlugins,
2016-09-21 00:58:31 +08:00
function () {
this.plugin('done', () =>
setTimeout(() => console.log('\nFinished at ' + (new Date).toLocaleTimeString() + '\n'), 10)
);
},
new webpack.HotModuleReplacementPlugin(),
]
2016-09-21 15:00:38 +08:00
});