-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.dev.js
73 lines (71 loc) · 2.2 KB
/
webpack.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
63
64
65
66
67
68
69
70
71
72
73
const common = require('./webpack.common.js')
const merge = require('webpack-merge')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const Autoprefixer = require('autoprefixer')
module.exports = merge(common, {
watch: true, // watch for changes in any of the resolved files
devServer: {
open: true, // Tells dev-server to open the browser after server had been started
overlay: true, // Shows a full-screen overlay with errors or warnings
hot: false // update changes without full refresh in the browser
},
watchOptions: {
ignored: /node_modules/,
aggregateTimeout: 1200 // Add a delay before rebuilding once the first file changed
},
mode: 'development', // Stop minify webpack JS bundle
devtool: 'none', // Simplify outputted bundle code for reader when development
plugins: [
new HtmlWebpackPlugin({ // Generate a file dist/index.html
template: './src/index.html', // Use html source
filename: './index.html' // Output html file into ./dist
})
],
module: {
rules: [
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
loader: 'eslint-loader',
options: {
// eslint options (if necessary)
}
},
{
test: /\.(scss|css)$/, // allow scss and css
use: [
{
loader: 'style-loader', // 4. Inject CSS into the DOM
options: {
sourceMap: true
}
},
{
loader: 'css-loader', // 3. Turns CSS into CommonJS
options: {
sourceMap: true
}
},
{
loader: 'postcss-loader', // 2. Process CSS with PostCSS
options: {
ident: 'postcss', // Parse CSS and add vendor prefixes
plugins: [
new Autoprefixer({
grid: true, // Activate CSS Grid polyfill (IE 10-11)
overrideBrowserslist: ['> 1%', 'last 2 versions']
})
]
}
},
{
loader: 'sass-loader', // 1. Turns sass into css
options: {
sourceMap: true
}
}
]
}
]
}
})