-
Notifications
You must be signed in to change notification settings - Fork 138
/
webpack.dev.js
60 lines (58 loc) · 1.72 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
const { readFileSync } = require('fs');
const path = require('path');
const webpack = require('webpack');
const { merge } = require('webpack-merge');
// const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const TerserPlugin = require('terser-webpack-plugin');
const base = require('./webpack.common');
// const withReport = process.env.npm_config_withReport;
const nodeEnv = process.env.NODE_ENV;
module.exports = merge(base, {
mode: 'development',
devtool: 'cheap-module-source-map',
output: {
clean: true,
globalObject: 'this',
filename: '[name].dev.js',
chunkFilename: '[name].dev.js',
path: `${__dirname}/build/${nodeEnv}`,
publicPath: '',
},
optimization: {
nodeEnv: 'development',
minimizer: [
new TerserPlugin({
parallel: 4,
minify: TerserPlugin.esbuildMinify,
// terserOptions: {
// sourceMap: 'external',
// },
}),
],
},
devServer: {
// server: 'https',
// https: {
// key: readFileSync('x-dev-certs/localhost.key.pem'),
// cert: readFileSync('x-dev-certs/localhost.cert.pem'),
// ca: readFileSync('x-dev-certs/ca/rootCA.pem'),
// },
static: path.join(__dirname, './build/development'),
compress: true,
port: 3000,
open: true,
hot: true,
allowedHosts: 'all',
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',
'Access-Control-Allow-Headers':
'X-Requested-With, content-type, Authorization',
},
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.IgnorePlugin({ resourceRegExp: /[^/]+\/[\S]+.dev$/ }),
// new BundleAnalyzerPlugin(),
],
});