-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.client.dev.conf.js
53 lines (48 loc) · 1.77 KB
/
webpack.client.dev.conf.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
const ip = require('ip')
const webpack = require('webpack')
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin')
const CircularDependencyPlugin = require('circular-dependency-plugin')
const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
const config = require('./webpack.base.conf.js')()
const serverConfig = require('./server.config')
const currentIP = ip.address()
// cheap-module-eval-source-map is faster for development
// config.devtool = '#cheap-module-eval-source-map'
// transformed code
config.devtool = '#cheap-eval-source-map'
const PUBLIC_PATH = `http://${currentIP}:${serverConfig.port + 100}`
// necessary for the html plugin to work properly
// when serving the html from in-memory
config.output.publicPath = `${PUBLIC_PATH}/public/`
config.module.rules.push(
{
test: /\.css$/,
use: ['style-loader', 'css-loader', 'postcss-loader'],
},
{
test: /\.styl$/,
use: ['style-loader', 'css-loader', 'postcss-loader', 'stylus-loader?resolve url'],
}
)
config.plugins = (config.plugins || []).concat([
// 由于mac不区分大小写,linux区分大小写,可能导致mac上正常,在部署时出错,所以强制区分大小写
new CaseSensitivePathsPlugin(),
// 循环依赖预警
new CircularDependencyPlugin({
// exclude detection of files based on a RegExp
exclude: /node_modules/,
// add errors to webpack instead of warnings
failOnError: true,
}),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"development"',
},
}),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
new FriendlyErrorsPlugin(),
// 查看依赖图,反注释即可开启
// new (require('webpack-bundle-analyzer').BundleAnalyzerPlugin),
])
module.exports = config