-
Notifications
You must be signed in to change notification settings - Fork 12
/
webpack.react.config.js
82 lines (81 loc) · 2.61 KB
/
webpack.react.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
82
const path = require('path');
const webpack = require('webpack');
const es3ifyPlugin = require('es3ify-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
devtool: 'cheap-module-source-map',
entry: {
production: path.resolve(__dirname, './views/production/app.jsx'),
},
output: {
path: path.resolve(__dirname, 'devtmp'),
filename: 'js/[name].js',
publicPath: '/',
chunkFilename: 'js/[name].js',
},
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,
},
],
'react',
'stage-2',
],
plugins: ['transform-runtime'],
},
},
include: [path.resolve(__dirname, 'views')],
},
{
test: /\.css$/,
include: [path.resolve(__dirname, 'views')],
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: 'production.html',
template: path.resolve(__dirname, './views/production/index.ejs'),
inject: 'body',
hase: false,
minify: {
// 压缩HTML文件
removeComments: true, // 移除HTML中的注释
collapseWhitespace: false, // 删除空白符与换行符
},
chunks: ['production'],
}),
],
};