-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.dev.config.js
59 lines (55 loc) · 1.76 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
const path = require('path');
const merge = require('webpack-merge');
const webpackCommonConfig = require('./webpack.common.config.js');
const env = process.env;
const LOCAL_HOST = env.npm_package_server_local_host;
const LOCAL_PORT = env.npm_package_server_local_port;
const MOCK_HOST = env.npm_package_server_mock_host;
const MOCK_PORT = env.npm_package_server_mock_port;
const urlAll = require('./src/global/url.js');
const webpackDev = {
devtool: 'cheap-module-eval-source-map',
mode: "development",
module: {
rules: [
{
/**
* eslint代码规范校验
*/
test: /\.(js|jsx)$/,
enforce: 'pre',
include: path.join(__dirname, 'src')
// use: [
// {
// loader: 'eslint-loader',
// options: {
// configFile: '.eslintrc.json'
// }
// }
// ]
}
]
},
devServer: {
host: LOCAL_HOST,
port: LOCAL_PORT,
disableHostCheck: true,
compress: true, // 开起 gzip 压缩
inline: true,
historyApiFallback: true,
contentBase: path.join(__dirname, './dist'),
proxy: {
'/mock': {
// matches paths starting with '/mock'
target: `http://${MOCK_HOST}:${MOCK_PORT}`,
pathRewrite: { '^/mock': '' }
},
'/api': {
// matches paths starting with '/api'
target: `http://${urlAll.url}`,
pathRewrite: { '^/api': '' }
}
}
}
};
module.exports = merge(webpackDev, webpackCommonConfig)