-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.prod.js
55 lines (49 loc) · 1.7 KB
/
webpack.prod.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
/* global require module */
const templatesDir = 'assets';
const path = require('path');
const webpack = require('webpack');
const WebpackMerge = require('webpack-merge');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const commonConfig = require('./webpack.common.js');
const config = require('./web/config');
const { getProcessedAppDomain } = require('./assets/common');
const copy = new CopyWebpackPlugin([
{
from: `${templatesDir}/manifest.json`,
transform: (content, path) =>
content.toString()
.replace(/#short-name#/g, `${config.friendlyName}`)
.replace(/#long-name#/g, `${config.friendlyName} - ${config.description}`)
.replace(/#static-path#/g, `${config.staticPath}`)
.replace(/#background-color#/g, `${config.colors.backgroundColor}`)
.replace(/#theme-color#/g, `${config.colors.themeColor}`)
}
]);
const html = new HtmlWebpackPlugin({
template: `${templatesDir}/index.ejs`,
templateParameters: {
viewportTag: config.viewportTag,
name: config.friendlyName,
title: `${config.friendlyName}: ${config.description}`,
description: config.description,
type: config.type,
appDomain: getProcessedAppDomain(config),
baseUrl: `${getProcessedAppDomain(config)}/${config.staticPath}/`
},
filename: 'index.html',
chunks: ['app'],
hash: true
});
module.exports = WebpackMerge(
commonConfig,
{
mode: 'production',
plugins: [
copy,
new UglifyJSPlugin(),
html
]
}
);