-
Notifications
You must be signed in to change notification settings - Fork 56
/
webpack.config.js
59 lines (58 loc) · 1.55 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
/*
* @file webpack配置文件(开发环境)
* @author tanjizhen
* @date 2017-04-30
*/
const path = require('path');
const webpack = require('webpack');
const OpenBrowserPlugin = require('open-browser-webpack-plugin');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const port = 3000;
module.exports = {
devtool: '#source-map',
entry: {
bundle: './app/main.jsx',
vendor: ['react', 'react-dom', 'jquery', 'react-router', 'redux'],
},
output: {
path: path.join(__dirname, '/build'),
filename: '[name].js',
},
resolve: {
extensions: ['.js', '.jsx'],
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
use: 'babel-loader',
},
{
test: /\.less$/,
use: [
'style-loader',
'css-loader?#sourceMap',
'postcss-loader',
'less-loader',
],
},
],
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({
name: ['vendor'],
}),
new OpenBrowserPlugin({
url: `http://localhost:${port}`
}),
new BundleAnalyzerPlugin()
],
devServer: {
compress: true, // 启用gzip压缩
contentBase: path.join(__dirname, 'app'),
port: port, // 运行端口3000
inline: true,
hot: true,
historyApiFallback: true,
},
};