-
Notifications
You must be signed in to change notification settings - Fork 293
/
Copy pathwebpack.config.js
62 lines (57 loc) · 1.73 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
var path = require('path')
var webpack = require('webpack')
var HtmlWebpackPlugin = require('html-webpack-plugin')
var ip = process.env.IP || '0.0.0.0'
var port = process.env.PORT || 3000
var DEBUG = process.env.NODE_ENV !== 'production'
var config = {
devtool: DEBUG ? 'eval' : false,
entry: [
'babel-polyfill',
path.join(__dirname, 'src')
],
output: {
path: path.join(__dirname, 'dist'),
filename: 'app.[hash].js',
publicPath: '/'
},
resolve: {
modulesDirectories: ['src', 'node_modules']
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': "'" + process.env.NODE_ENV + "'"
}),
new HtmlWebpackPlugin({
filename: 'index.html',
template: path.join(__dirname, '/public/index.html')
})
],
module: {
loaders: [
{ test: /\.js$/, loader: 'babel', exclude: /node_modules/ },
{ test: /\.png$/, loader: 'url?prefix=images/&limit=8000&mimetype=image/png' },
{ test: /\.jpg$/, loader: 'url?prefix=images/&limit=8000&mimetype=image/jpeg' },
{ test: /\.woff$/, loader: 'url?prefix=fonts/&limit=8000&mimetype=application/font-woff' },
{ test: /\.ttf$/, loader: 'file?prefix=fonts/' },
{ test: /\.eot$/, loader: 'file?prefix=fonts/' },
{ test: /\.json$/, loader: 'json' }
]
}
}
if (DEBUG) {
config.entry.unshift(
'webpack-dev-server/client?http://' + ip + ':' + port + '/',
'webpack/hot/only-dev-server',
'react-hot-loader/patch'
)
config.plugins = config.plugins.concat([
new webpack.HotModuleReplacementPlugin()
])
} else {
config.plugins = config.plugins.concat([
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } })
])
}
module.exports = config