webpack4之eslint配置


配置
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
# npm i -D eslint eslint-loader eslint-friendly-formatter
# npx eslint --init
// 选择 To check syntax, find problems, and enforce code style, 其他看具体情况

// webpack.config.js
module.exports = {
module: {
rules: [{
test: /\.js$/,
exclude: /node_modules/,
enforce: 'pre',
include: [path.resolve(__dirname, '../src')],
use: ['babel-loader', {
loader: 'eslint-loader',
options: {
formatter: require('eslint-friendly-formatter'),
emitWarning: true // true:只显示在控制台上,false:并显示在页面上
}
}
}]
},
devServer: {
overlay: true, // eslint和webpackDevServer结合
historyApiFallback: true,
contentBase: './sef', // 监听打包的文件夹
proxy: {
'/api': 'http://localhost:3000', // 代理
'/react/api': {
tartget: 'http://www.dell-lee.com',
secure: false,
changeOrigin: true
}
},
open: true,
port: 8081
}
}