-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
81 lines (78 loc) · 2.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
79
80
81
var webpack = require('webpack');
var autoprefixer = require('autoprefixer');
var precss = require('precss');
var path = require('path');
var exp = {
devServer: {
host: '0.0.0.0',
port: 8090,
historyApiFallback: {
index: '/'
}
},
entry: {
bundle: './www/index.jsx'
},
output: {
path: path.join(__dirname, 'assets'),
filename: '[name].js',
publicPath: '/assets/'
},
module: {
preLoaders: [
{ test: /\.jsx?$/, exclude: /node_modules/, loader: 'eslint-loader' }
],
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {
presets: ['es2015', 'react']
}
},
{ test: /\.json$/, loader: 'json-loader' },
{ test: /\.png$/, loader: 'url-loader?limit=10000&minetype=image/png' },
{ test: /\.jpg$/, loader: 'url-loader?limit=10000&minetype=image/jpg' },
{ test: /\.gif$/, loader: 'url-loader?limit=10000&minetype=image/gif' },
{
test: /\.scss$/,
loaders: ['style', 'css', 'postcss', 'sass']
},
{ test: /\.css$/, loaders: ['style', 'css', 'postcss'] },
{
test: /\.(eot|svg|ttf|woff(2)?)(\?v=\d+\.\d+\.\d+)?/,
loader: 'url-loader'
}
]
},
postcss: function () {
return [autoprefixer, precss];
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.DefinePlugin({
'process.env': {
browser: true
}
})
],
externals: {},
resolve: {
extensions: ['', '.js', '.jsx']
}
};
if (process.argv && process.argv.indexOf('--production') != -1) {
exp.plugins.push(
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production')
}
})
);
}
else {
exp.entry.webpack = 'webpack-dev-server/client?http://0.0.0.0:8090';
exp.entry.webpackHot = 'webpack/hot/only-dev-server';
}
module.exports = exp;