-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.build.js
31 lines (29 loc) · 871 Bytes
/
webpack.build.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
/**
* 生产环境 webpack 配置
*/
const pathBuilder = require('path');
// html 模版编译插件
const HtmlWebpackPlugin = require('html-webpack-plugin');
// 基本 webpack 配置
const generateBaseConfig = require('./webpack.base.js');
// 编译生产环境使用的html模版
const buildTemplateHtmlPath = pathBuilder.resolve('template.index.html');
module.exports = function (env) {
const { output: out = '.' } = env;
const outputParts = out.split('/');
const config = generateBaseConfig(env, 'production');
return {
...config,
entry: {
bundle: pathBuilder.resolve('src', 'index.tsx')
},
plugins: config.plugins.concat([
new HtmlWebpackPlugin({
plugin: 'html',
filename: pathBuilder.resolve(...outputParts, 'index.html'),
template: buildTemplateHtmlPath,
inject: true
})
])
};
};