-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathwebpack.config.js
77 lines (75 loc) · 1.95 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
const HtmlWebpackPlugin = require('html-webpack-plugin')
const CleanWebpackPlugin = require('clean-webpack-plugin')
const path = require('path')
const webpack = require('webpack')
const isProduction = process.env.NODE_ENV === 'production'
module.exports = {
performance: {
hints: false
},
devtool: !isProduction && 'cheap-eval-source-map',
entry: `./src/index.js`,
output: {
path: path.join(__dirname, 'dist'),
filename: 'index.js',
publicPath: '' // relative to HTML page (same directory)
},
module: {
rules: [
{
test: /\.css$/,
use: [ 'style-loader', 'css-loader' ]
},
{
test: /\.(jpe?g|png|ttf|eot|svg|woff(2)?|webm)(\?[a-z0-9=&.]+)?$/,
use: 'file-loader?name=[name].[ext]'
},
{
test: /\.js(x)?$/,
exclude: path.join(__dirname, 'node_modules'),
loaders: [{
loader: 'babel-loader',
options: {
cacheDirectory: true,
babelrc: false,
presets: [
'react',
['env', {
targets: {
chrome: '33'
}
}]
],
plugins: [
'transform-runtime',
'transform-decorators-legacy',
'transform-object-rest-spread',
'transform-export-extensions',
'transform-function-bind',
'transform-class-properties',
'transform-react-jsx-source'
]
}
}]
}
]
},
plugins: [
new CleanWebpackPlugin([ path.join(__dirname, 'dist') ]),
new HtmlWebpackPlugin({
filename: 'index.html',
template: path.join(__dirname, 'index.html')
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
}),
...(
isProduction ? [
new webpack.optimize.UglifyJsPlugin()
] : []
)
],
externals: {
ws: 'WebSocket'
}
}