-
Notifications
You must be signed in to change notification settings - Fork 3
/
webpack.config.js
72 lines (70 loc) · 2.03 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
const path = require('path');
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const cssExtract = new ExtractTextPlugin('styles.css');
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
module.exports = {
entry: {
entry: [
'babel-polyfill',
'react-hot-loader/patch',
'./client/index.jsx',
],
vendor: ['react', 'react-dom', 'react-redux', 'react-router'],
},
output: { //create output path
filename: '[name].bundle.js',
path: path.join(__dirname, 'client', 'public', 'dist'),
hotUpdateChunkFilename: 'hot/hot-update.js',
hotUpdateMainFilename: 'hot/hot-update.json'
},
module: {
rules: [
{
test: /\.(js|jsx)$/, // checks for any files ending in .js or .jsx
exclude: [/node_modules/], // doesn't include node modules
use: ['babel-loader'], // uses babel as transpiler
},
{
test: /\.(css|sass|scss)$/, // checks for any files ending in .css, .sass, or .scss
use: process.env.NODE_ENV === 'production' ?
cssExtract.extract({
use: ['css-loader', 'sass-loader']
}) :
['style-loader', 'css-loader', 'sass-loader']
},
{
test: /\.(jpe?g|png|gif|svg)$/i,
loader: 'url-loader?limit=30000&name=images/[name].[ext]'
},
]
},
devServer: {
contentBase: './client/public',
publicPath: '/dist/',
historyApiFallback: true,
hot: true
},
plugins: process.env.NODE_ENV === 'production' ?
[
cssExtract,
new webpack.optimize.ModuleConcatenationPlugin(),
new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
beautify: false,
comments: false,
compress: {
warnings: false,
drop_console: true,
screw_ie8: true
},
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
}),
] :
[
new webpack.HotModuleReplacementPlugin(),
],
devtool: process.env.NODE_ENV === 'production' ? 'source-map' : 'cheap-module-eval-source-map',
};