-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.base.config.js
81 lines (80 loc) · 2.67 KB
/
webpack.base.config.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
const path = require('path');
const es3ifyPlugin = require('es3ify-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: {
app: path.resolve(__dirname, './src/app.jsx'),
},
output: {
path: path.resolve(__dirname, 'dist'),
},
resolve: {
extensions: ['.js', '.json', '.jsx'],
},
module: {
rules: [
{
test: /\.jsx?$/,
use: {
loader: 'babel-loader',
options: {
presets: [
[
'env',
{
targets: {
browsers: ['last 2 versions', 'ie >= 7'],
},
modules: 'commonjs',
useBuiltIns: true,
debug: false,
exclude: [
'es6.symbol',
'es6.object.assign'
]
},
],
'react',
'stage-2',
],
plugins: ['transform-runtime'],
},
},
include: [path.resolve(__dirname, 'src')],
},
{
test: /\.css$/,
include: [path.resolve(__dirname, 'src')],
use: ['style-loader', 'css-loade'],
},
{
test: /\.(eot|woff|woff2|ttf|svg|png|jpg|gif)$/,
use: [
{
loader: 'url-loader',
options: {
limit: 100,
name: 'asset/[name].[ext]',
},
},
],
},
],
},
mode: 'development',
plugins: [
new es3ifyPlugin(),
new HtmlWebpackPlugin({
filename: 'index.html',
template: path.resolve(__dirname, './src/index.ejs'),
inject: 'body',
hase: false,
minify: {
// 压缩HTML文件
removeComments: true, // 移除HTML中的注释
collapseWhitespace: false, // 删除空白符与换行符
},
chunks: ['app'],
}),
],
};