This repository has been archived by the owner on Jan 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathwebpack.prod.js
104 lines (101 loc) · 3.82 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
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
const path = require("path");
const { merge } = require("webpack-merge");
const common = require("./webpack.common.js");
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
const CopyPlugin = require("copy-webpack-plugin");
const TerserJSPlugin = require("terser-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const HtmlReplaceWebpackPlugin = require("html-replace-webpack-plugin");
const { crc } = require("./package.json");
const AppServicesUiComponentsPath = `node_modules/@rhoas/app-services-ui-components`;
const publicPath = "/apps/application-services/";
module.exports = merge(
common("production", { mode: "production", publicPath }),
{
mode: "production",
devtool: "source-map",
optimization: {
sideEffects: true,
minimizer: [
new TerserJSPlugin({}),
new CssMinimizerPlugin({
minimizerOptions: {
processorOptions: {
preset: ["default", { mergeLonghand: false }], // Fixes bug in PF Select component https://github.com/patternfly/patternfly-react/issues/5650#issuecomment-822667560
},
},
}),
],
},
plugins: [
new HtmlWebpackPlugin({
template: path.resolve(__dirname, "src", "index.html"),
templateParameters: {
appName: crc.bundle,
},
inject: false,
minify: {
collapseWhitespace: true,
keepClosingSlash: true,
removeComments: true,
removeRedundantAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true,
useShortDoctype: true,
minifyJS: true,
},
}),
new HtmlReplaceWebpackPlugin([
{
pattern: "@@env",
replacement: publicPath,
},
]),
new CopyPlugin({
patterns: [
{
from: "config/config.json",
to: `config.json`,
},
// Copy the logos for the service, for usage by third parties
{
from: `${AppServicesUiComponentsPath}/static/images/Logo-Red_Hat-OpenShift_Streams_for_Apache_Kafka-A-White-RGB.png`,
to: "Logo-Red_Hat-OpenShift_Streams_for_Apache_Kafka-A-White-RGB.png",
},
{
from: `${AppServicesUiComponentsPath}/static/images/Logo-Red_Hat-OpenShift_Streams_for_Apache_Kafka-A-Reverse-RGB.png`,
to: "Logo-Red_Hat-OpenShift_Streams_for_Apache_Kafka-A-Reverse-RGB.png",
},
{
from: `${AppServicesUiComponentsPath}/static/images/Logo-Red_Hat-OpenShift_Streams_for_Apache_Kafka-A-Standard-RGB.png`,
to: "Logo-Red_Hat-OpenShift_Streams_for_Apache_Kafka-A-Standard-RGB.png",
},
{
from: `${AppServicesUiComponentsPath}/static/images/Logo-Red_Hat-OpenShift-Application_Services-A-Reverse-RGB.svg`,
to: "Logo-Red_Hat-OpenShift-Application_Services-A-Reverse-RGB.svg",
},
{
from: `${AppServicesUiComponentsPath}/static/images/Logo-Red_Hat-OpenShift_Streams_for_Apache_Kafka-A-Reverse-RGB-310x117.png`,
to: "Logo-Red_Hat-OpenShift_Streams_for_Apache_Kafka-A-Reverse-RGB-310x117.png",
},
{
from: `${AppServicesUiComponentsPath}/static/images/Logo-Red_Hat-OpenShift-API_Management-A-Standard-RGB.svg`,
to: "Logo-Red_Hat-OpenShift-API_Management-A-Standard-RGB.svg",
},
// Deprecated - should be removed after 01/04/2022
{
from: "static/configs/terms-conditions-spec.json",
to: "terms-conditions-spec.json",
},
{
from: "static/configs/service-constants.json",
to: "service-constants.json",
},
],
}),
],
output: {
filename: "[name].[contenthash].js",
},
}
);