-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
34 lines (33 loc) · 973 Bytes
/
webpack.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
const path = require('path');
const webpack = require('webpack');
const pkg = require('./package.json'); // 引入package.json
const baseConfig = require("./webpack.base.config");
const CleanWebpackPlugin = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const merge = require("webpack-merge");
const env = process.env.WEBPACK_ENV;
module.exports = merge(baseConfig, {
output: {
filename: '[name].[chunkhash:5].js',
chunkFilename: '[name].[chunkhash:5].js',
path: path.resolve(__dirname, 'dist')
},
mode: env,
optimization: {
minimize: true, // 压缩代码,替代optimize.UglifyJsPlugin
splitChunks: {
chunks: "all",
},
runtimeChunk: {
name: "manifest" // webpack模块依赖的初始化代码和依赖关系的hash映射
},
},
plugins: [
new CleanWebpackPlugin('dist'),
new HtmlWebpackPlugin({
title: 'webpack4 入门教程',
template: './index.html',
environment: env,
}),
]
});