-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.dev.config.js
67 lines (54 loc) · 1.73 KB
/
webpack.dev.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
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const config = {
entry: path.resolve(__dirname, 'src/index.js'),
output: {
/* put 'bundle.js' to folder 'public' after transpiling, as same value as devServer.contentBase */
path: path.resolve(__dirname, 'public'),
filename: '[name].js'
},
module: {
rules: [
{
test: /\.js$/,
use: ['babel-loader'],
exclude: /node_modules/
},
{
test: /\.css$/,
loader: 'style-loader!css-loader'
}
]
},
devtool: 'source-map',
devServer: {
/* when inline is true, it enables 'auto refresh' and 'hot module replacement' */
inline: true,
/* default port for webpack-dev-server*/
port: 3000,
/* specify folder that webpack-dev-server will transpile bundle.js to, as same value as output.path */
contentBase: 'public/',
/* publicPath is virtual path on webpack server */
publicPath: '/'
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: function (module) {
return module.context && module.context.indexOf('node_modules') !== -1;
}
}),
new HtmlWebpackPlugin({
/* input html file */
template: 'src/templates/index.html',
/* output html file to virtual path , it is fully accessed by http://localhost/index.html */
filename: 'index.html'
})
]
};
module.exports = config;
/*
new webpack.NoEmitOnErrorsPlugin()
UglifyPlugin
* */