-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.dev.js
74 lines (72 loc) · 1.76 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
const path = require('path');
const { merge } = require('webpack-merge');
const commonConfig = require('./webpack.common');
module.exports = merge(commonConfig, {
mode: 'development',
devtool: 'cheap-module-source-map',
output: {
filename: '[name].js',
},
target: 'web',
devServer: {
static: [path.join(process.cwd(), 'public')],
compress: true,
host: 'localhost',
port: 9001,
liveReload: true,
// // 设置代理
// proxy: {
// // 将本地 /api/xxx 代理到 localhost:3000/api/xxx
// '/api': 'http://localhost:3000',
// // 将本地 /api2/xxx 代理到 localhost:3000/xxx
// '/api2': {
// target: 'http://localhost:3000',
// pathRewrite: {
// '/api2': '',
// },
// // resolve cors problem
// changeOrigin: true,
// },
// },
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
enforce: 'pre',
use: ['source-map-loader'],
},
{
test: /\.s?css$/,
use: [
'style-loader',
{
loader: 'css-loader',
options: {
modules: {
auto: (resourcePath) => !resourcePath.includes('node_modules'),
localIdentName: '[name]__[local]__[hash:base64:5]',
},
},
},
{
loader: 'postcss-loader',
options: {
postcssOptions: {
plugins: [['postcss-preset-env']],
},
sourceMap: true,
},
},
{
loader: 'sass-loader',
options: { sourceMap: true },
},
],
},
],
},
plugins: [
// new CopyPlugin({ patterns: [{ from: '', to: '' }] }),
],
});