-
Notifications
You must be signed in to change notification settings - Fork 4
/
webpack.config.js
78 lines (75 loc) · 2 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
var path = require('path');
var webpack = require('webpack');
var port = process.env.PORT || 3000;
var env = process.env.NODE_ENV || 'development';
var plugins = [];
var entries = ['./src/app'];
var loaders = ['babel?stage=0'];
if (env === 'production') {
plugins = [
new webpack.optimize.UglifyJsPlugin()
];
} else if (env === 'development') {
plugins = [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
})
];
entries.push('webpack-dev-server/client?http://0.0.0.0:' + port, 'webpack/hot/only-dev-server');
loaders.unshift('react-hot');
}
module.exports = {
devtool: 'eval',
entry: entries,
output: {
path: path.join(__dirname, 'build/assets'),
filename: 'bundle.js',
publicPath: 'assets/'
},
plugins: plugins,
resolve: {
extensions: ['', '.js', '.jsx', '.yml']
},
module: {
loaders: [{
test: /\.jsx?$/,
loaders: loaders,
exclude: /node_modules/,
include: path.join(__dirname, 'src')
}, {
test: /\.less$/,
loader: ['style!css!less']
}, {
test: /\.gif/,
loader: 'url-loader?limit=10000&mimetype=image/gif'
}, {
test: /\.jpg/,
loader: 'url-loader?limit=10000&mimetype=image/jpg'
}, {
test: /\.png/,
loader: 'url-loader?limit=10000&mimetype=image/png'
}, {
test: /\.svg/,
loader: 'url-loader?limit=10000&mimetype=image/svg+xml'
}, {
test: /\.woff$/,
loader: "url-loader?limit=10000&mimetype=application/font-woff"
}, {
test: /\.ttf$/,
loader: "url-loader?limit=10000&mimetype=application/octet-stream"
}, {
test: /\.eot$/,
loader: "file-loader"
}, {
test: /\.svg$/,
loader: "url-loader?limit=10000&mimetype=image/svg+xml"
}],
preLoaders: [
{test: /\.jsx?$/, loader: 'eslint', exclude: /build|data|node_modules/},
]
},
eslint: {configFile: '.eslintrc'},
port: port
};