This repository has been archived by the owner on Sep 28, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
86 lines (85 loc) · 1.82 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
const { resolve } = require('path')
const webpack = require('webpack')
const src = resolve(__dirname, 'src')
const pub = resolve(__dirname, 'public')
const isProd = process.env.NODE_ENV === 'production'
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
module.exports = {
devtool: isProd ? 'source-map' : 'cheap-eval-source-map'
, context: resolve(__dirname)
, entry: isProd ? './src/index.js' : [
'webpack-dev-server/client?http://127.0.0.1:8080'
, 'webpack/hot/only-dev-server'
, './src/index.js'
]
, output: isProd ? {
filename: 'bundle.js'
, path: pub
} : {
filename: 'bundle.js'
, path: pub
, publicPath: 'http://127.0.0.1:8080/'
}
, module: {
rules: [
{
test: /\.js$/
, include: src
, use: 'babel-loader'
}
, {
test: /\.css$/
, include: src
, use: [
'style-loader'
, {
loader: 'css-loader'
, options: {
modules: true
, importLoaders: 1
, localIdentName: '[local]__[hash:base64:9]'
}
}
, 'postcss-loader'
]
}
]}
, devServer: {
contentBase: './public'
, historyApiFallback: true
, hot: true
, stats: { colors: true }
, overlay: false
}
, plugins: isProd ? [
new webpack.DefinePlugin({
'process.env': { NODE_ENV: JSON.stringify('production') }
})
, new UglifyJsPlugin({
compress: {
screw_ie8: true,
warnings: false
},
mangle: {
screw_ie8: true
},
output: {
comments: false,
screw_ie8: true
}
})
] : [
new webpack.HotModuleReplacementPlugin()
, new webpack.LoaderOptionsPlugin({ debug: true })
]
, resolve: {
extensions : ['.js', '.css']
}
, node: {
fs: 'empty'
, net: 'empty'
, tls: 'empty'
, readline: 'empty'
, child_process: 'empty'
}
}