-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
86 lines (82 loc) · 2.17 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
var webpack = require('webpack');
var path = require('path');
var devConfig = {
context: __dirname,
entry: [
// Add the client which connects to our middleware
// You can use full urls like 'webpack-hot-middleware/client?path=http://localhost:3000/__webpack_hmr'
// useful if you run your app from another point like django
//'webpack-hot-middleware/client',//?path=/__webpack_hmr&timeout=20000',
'webpack-hot-middleware/client?path=/__webpack_hmr&timeout=20000',
// And then the actual application
'./client/src/index'
],
output: {
path: path.join(__dirname, 'client/dist'),
path: __dirname,
publicPath: 'http://localhost:3000/',
filename: './client/dist/bundle.js'
},
devtool: '#source-map',
module: {
loaders: [
{
test: /\.js?/,
loaders: ['babel'],
include: path.join(__dirname, 'client/src')
},
{
test: /\.json$/,
loader: "json-loader"
},
{
test: /\.scss?/,
loaders: ['style', 'css', 'sass']
},
{
test: /\.css$/,
loaders: ['style', 'css' ]
},
{
test: /\.(png|jpg|gif|svg)$/,
loader: 'file-loader?name=[path][name].[ext]',
//exclude: [/fontawesome.*$/i]
}]
},
plugins: [
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
new webpack.ProvidePlugin({
'fetch': 'imports?this=>global!exports?global.fetch!whatwg-fetch'
})
],
resolve: {
modulesDirectories: ['node_modules', 'bower_components'],
extensions: ['', '.js', '.jsx']
}
};
if (process.env.NODE_ENV === 'production') {
devConfig.entry = [
'./client/src/index'
];
devConfig.plugins = [
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production')
}
}),
new webpack.ProvidePlugin({
'fetch': 'imports?this=>global!exports?global.fetch!whatwg-fetch'
}),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin({
compressor: {
warnings: false
}
})
];
delete devConfig.devtool;
}
module.exports = devConfig;