-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.dev.js
62 lines (58 loc) · 1.4 KB
/
webpack.config.dev.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
const merge = require('webpack-merge')
const webpack = require('webpack')
const common = require('./webpack.config.common')
const user = require('./scripts/utils/format-config')(require('./main.config.js'))
const cssLoaders = (
[
{
loader: 'style-loader',
options: {
sourceMap: true,
singleton: true // avoid CSS Flashing
}
}
].concat(common.CSSLoaders)
)
// append resolve-url-loader before the preprocessor loader so that
// we can avoid broken relative url with the dev server
if (user.css.preprocessorLoader) {
for (let i = 0; i < cssLoaders.length; i++) {
const obj = cssLoaders[i]
if (obj.loader !== user.css.preprocessorLoader) continue
cssLoaders.splice(i, 0,
{
loader: 'resolve-url-loader',
options: { sourceMap: true }
}
)
break
}
}
const devConfig = {
mode: 'development',
entry: user.entries,
module: {
rules: [
{
test: user.css.sourceRegexExt,
use: cssLoaders
},
{
test: /\.(svg|png|jpg|gif|ttf|otf|woff|woff2|eot)$/,
use: [
{
loader: 'file-loader',
options: {}
}
]
}
]
},
plugins: [
new webpack.NoEmitOnErrorsPlugin(),
new webpack.NamedModulesPlugin(),
new webpack.HotModuleReplacementPlugin()
],
devtool: '#eval-source-map'
}
module.exports = merge(common.webpack, devConfig)