-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.dev.js
117 lines (108 loc) · 2.54 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
const { posix } = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin');
const merge = require('webpack-merge');
const baseConfig = require('./webpack.base');
const proxyConfig = require('./dev-proxy');
const CONFIG = {
port: 80,
host: '0.0.0.0',
};
baseConfig.module.rules.find(
rule => rule.loader === 'babel-loader',
).options.cacheDirectory = true;
module.exports = merge(baseConfig, {
mode: 'development',
devtool: 'cheap-module-source-map',
output: {
filename: 'js/[name].js',
chunkFilename: 'js/[name].chunk.js',
/**
* TODO: this is a temporary fix for resolve bugs caused by webpack hot reload in web worker.
* see this for more detail: https://github.com/webpack/webpack/issues/6642
*/
globalObject: 'this',
},
module: {
rules: [
{
test: /\.css$/i,
use: [
{
loader: 'style-loader',
options: {
sourceMap: true,
},
},
{
loader: 'css-loader',
options: {
sourceMap: true,
},
},
],
},
{
test: /\.s(a|c)ss$/i,
use: [
{
loader: 'style-loader',
options: {
sourceMap: true,
},
},
{
loader: 'css-loader',
options: {
sourceMap: true,
importLoaders: 1,
},
},
{
loader: 'sass-loader',
options: {
sourceMap: true,
},
},
],
},
],
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'src/index.html',
inject: true,
}),
new FriendlyErrorsPlugin({
compilationSuccessInfo: {
messages: [
`Your application is running here: http://${CONFIG.host}:${CONFIG.port}`,
],
},
}),
],
devServer: {
clientLogLevel: 'warning',
historyApiFallback: {
rewrites: [
{
from: /.*/,
to: posix.join(baseConfig.output.publicPath, 'index.html'),
},
],
},
hot: true,
contentBase: false,
compress: true,
disableHostCheck: true,
host: CONFIG.host,
port: CONFIG.port,
overlay: true,
publicPath: baseConfig.output.publicPath,
quiet: true,
proxy: proxyConfig,
},
});