@elliemae/pui-cli 5.19.0 → 5.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/webpack/helpers.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
/* eslint-disable max-lines */
|
|
1
2
|
const path = require('path');
|
|
2
3
|
const fs = require('fs');
|
|
3
4
|
const _ = require('lodash');
|
|
5
|
+
const CompressionPlugin = require('compression-webpack-plugin');
|
|
6
|
+
const zlib = require('zlib');
|
|
4
7
|
|
|
5
8
|
let pathSep = path.sep;
|
|
6
9
|
if (pathSep === '\\')
|
|
@@ -122,7 +125,6 @@ const getAppLoaderFileName = () => {
|
|
|
122
125
|
|
|
123
126
|
const getDiagnosticsFileName = () => {
|
|
124
127
|
const libName = 'emuiDiagnostics';
|
|
125
|
-
// eslint-disable-next-line max-lines
|
|
126
128
|
const libPath = path.join(
|
|
127
129
|
process.cwd(),
|
|
128
130
|
'node_modules/@elliemae/pui-diagnostics/dist/public/js',
|
|
@@ -185,6 +187,38 @@ const isGoogleTagManagerEnabled = () => {
|
|
|
185
187
|
return !!appConfig?.googleTagManager;
|
|
186
188
|
};
|
|
187
189
|
|
|
190
|
+
const getCompressionPlugins = () => {
|
|
191
|
+
const commonConfig = {
|
|
192
|
+
test: /\.(js|css)$/,
|
|
193
|
+
exclude: [
|
|
194
|
+
/\/adrum-ext/,
|
|
195
|
+
/\/emuiUserMonitoring/,
|
|
196
|
+
/\/emuiDiagnostics/,
|
|
197
|
+
/\/emuiAppLoader/,
|
|
198
|
+
/\/encwLoader/,
|
|
199
|
+
],
|
|
200
|
+
// we are compressing all files since in aws cloudfront edge lambda, we don't want to whitelist files that are not compressed due to below limits
|
|
201
|
+
minRatio: Number.MAX_SAFE_INTEGER,
|
|
202
|
+
};
|
|
203
|
+
return [
|
|
204
|
+
new CompressionPlugin({
|
|
205
|
+
filename: '[path][base].gz',
|
|
206
|
+
algorithm: 'gzip',
|
|
207
|
+
...commonConfig,
|
|
208
|
+
}),
|
|
209
|
+
new CompressionPlugin({
|
|
210
|
+
filename: '[path][base].br',
|
|
211
|
+
algorithm: 'brotliCompress',
|
|
212
|
+
...commonConfig,
|
|
213
|
+
compressionOptions: {
|
|
214
|
+
params: {
|
|
215
|
+
[zlib.constants.BROTLI_PARAM_QUALITY]: 11,
|
|
216
|
+
},
|
|
217
|
+
},
|
|
218
|
+
}),
|
|
219
|
+
];
|
|
220
|
+
};
|
|
221
|
+
|
|
188
222
|
exports.excludeNodeModulesExcept = excludeNodeModulesExcept;
|
|
189
223
|
exports.getLibraryName = getLibraryName;
|
|
190
224
|
exports.getAppConfig = getAppConfig;
|
|
@@ -209,3 +243,4 @@ exports.resolveExtensions = [
|
|
|
209
243
|
];
|
|
210
244
|
exports.mainFields = ['browser', 'module', 'main'];
|
|
211
245
|
exports.isGoogleTagManagerEnabled = isGoogleTagManagerEnabled;
|
|
246
|
+
exports.getCompressionPlugins = getCompressionPlugins;
|
|
@@ -64,21 +64,29 @@ const plugins = [
|
|
|
64
64
|
{
|
|
65
65
|
from: 'node_modules/@elliemae/pui-user-monitoring/dist/public/js',
|
|
66
66
|
to: 'js',
|
|
67
|
+
toType: 'dir',
|
|
68
|
+
info: { minimized: true },
|
|
67
69
|
},
|
|
68
70
|
{
|
|
69
|
-
from: 'node_modules/@elliemae/pui-app-loader/dist/public/js
|
|
70
|
-
to: 'js
|
|
71
|
+
from: 'node_modules/@elliemae/pui-app-loader/dist/public/js',
|
|
72
|
+
to: 'js',
|
|
73
|
+
toType: 'dir',
|
|
71
74
|
noErrorOnMissing: true,
|
|
75
|
+
info: { minimized: true },
|
|
72
76
|
},
|
|
73
77
|
{
|
|
74
|
-
from: 'node_modules/@elliemae/encw-loader/dist/public/js
|
|
75
|
-
to: 'js
|
|
78
|
+
from: 'node_modules/@elliemae/encw-loader/dist/public/js',
|
|
79
|
+
to: 'js',
|
|
80
|
+
toType: 'dir',
|
|
76
81
|
noErrorOnMissing: true,
|
|
82
|
+
info: { minimized: true },
|
|
77
83
|
},
|
|
78
84
|
{
|
|
79
|
-
from: 'node_modules/@elliemae/pui-diagnostics/dist/public/js
|
|
80
|
-
to: 'js
|
|
85
|
+
from: 'node_modules/@elliemae/pui-diagnostics/dist/public/js',
|
|
86
|
+
to: 'js',
|
|
87
|
+
toType: 'dir',
|
|
81
88
|
noErrorOnMissing: true,
|
|
89
|
+
info: { minimized: true },
|
|
82
90
|
},
|
|
83
91
|
{
|
|
84
92
|
from: 'public',
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
const TerserPlugin = require('terser-webpack-plugin');
|
|
3
|
-
const CompressionPlugin = require('compression-webpack-plugin');
|
|
4
3
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
5
4
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
6
5
|
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
|
|
7
6
|
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
|
|
8
|
-
const { getLibraryName } = require('./helpers');
|
|
7
|
+
const { getLibraryName, getCompressionPlugins } = require('./helpers');
|
|
9
8
|
|
|
10
9
|
const libraryName = getLibraryName();
|
|
11
10
|
|
|
@@ -69,13 +68,7 @@ module.exports = require('./webpack.lib.base.babel')({
|
|
|
69
68
|
chunkFilename: `css/${libraryName}.[contenthash].chunk.css`,
|
|
70
69
|
}),
|
|
71
70
|
|
|
72
|
-
|
|
73
|
-
filename: '[path][base].gz',
|
|
74
|
-
algorithm: 'gzip',
|
|
75
|
-
test: /\.js$|\.css$$/,
|
|
76
|
-
// we are compressing all files since in aws cloudfront edge lambda, we don't want to whitelist files that are not compressed due to below limits
|
|
77
|
-
minRatio: Number.MAX_SAFE_INTEGER,
|
|
78
|
-
}),
|
|
71
|
+
...getCompressionPlugins(),
|
|
79
72
|
|
|
80
73
|
new BundleAnalyzerPlugin({
|
|
81
74
|
analyzerMode: 'static',
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
/* eslint-disable max-lines */
|
|
1
2
|
const path = require('path');
|
|
2
3
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
3
4
|
const { GenerateSW } = require('workbox-webpack-plugin');
|
|
4
5
|
const TerserPlugin = require('terser-webpack-plugin');
|
|
5
|
-
const CompressionPlugin = require('compression-webpack-plugin');
|
|
6
6
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
7
7
|
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
|
|
8
8
|
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
|
|
@@ -15,6 +15,7 @@ const {
|
|
|
15
15
|
getPaths,
|
|
16
16
|
getAppVersion,
|
|
17
17
|
isGoogleTagManagerEnabled,
|
|
18
|
+
getCompressionPlugins,
|
|
18
19
|
} = require('./helpers');
|
|
19
20
|
|
|
20
21
|
const getProdConfig = ({ latestVersion = true } = {}) => {
|
|
@@ -74,14 +75,7 @@ const getProdConfig = ({ latestVersion = true } = {}) => {
|
|
|
74
75
|
chunkFilename: 'css/[name].[contenthash].chunk.css',
|
|
75
76
|
}),
|
|
76
77
|
|
|
77
|
-
|
|
78
|
-
filename: '[path][base].gz',
|
|
79
|
-
algorithm: 'gzip',
|
|
80
|
-
test: /\.js$|\.css$$/,
|
|
81
|
-
exclude: [/\/adrum-ext/, /\/emuiUserMonitoring/],
|
|
82
|
-
// we are compressing all files since in aws cloudfront edge lambda, we don't want to whitelist files that are not compressed due to below limits
|
|
83
|
-
minRatio: Number.MAX_SAFE_INTEGER,
|
|
84
|
-
}),
|
|
78
|
+
...getCompressionPlugins(),
|
|
85
79
|
|
|
86
80
|
new BundleAnalyzerPlugin({
|
|
87
81
|
analyzerMode: 'static',
|
|
@@ -120,7 +114,6 @@ const htmlWebpackPlugin = new HtmlWebpackPlugin({
|
|
|
120
114
|
? 'app/index.html'
|
|
121
115
|
: 'app/index-app-loader.html',
|
|
122
116
|
minify: {
|
|
123
|
-
// eslint-disable-next-line max-lines
|
|
124
117
|
removeComments: true,
|
|
125
118
|
collapseWhitespace: true,
|
|
126
119
|
removeRedundantAttributes: true,
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
const webpack = require('webpack');
|
|
3
3
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
4
4
|
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
|
5
|
-
const CompressionPlugin = require('compression-webpack-plugin');
|
|
6
5
|
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
|
|
7
6
|
const {
|
|
8
7
|
getAppConfig,
|
|
@@ -13,6 +12,7 @@ const {
|
|
|
13
12
|
resolveExtensions,
|
|
14
13
|
mainFields,
|
|
15
14
|
getMediaPath,
|
|
15
|
+
getCompressionPlugins,
|
|
16
16
|
} = require('./helpers');
|
|
17
17
|
|
|
18
18
|
const IS_APP = isApp();
|
|
@@ -50,14 +50,6 @@ const getAdditionalPlugins = () => [
|
|
|
50
50
|
}),
|
|
51
51
|
];
|
|
52
52
|
|
|
53
|
-
const compressionPlugin = new CompressionPlugin({
|
|
54
|
-
filename: '[path][base].gz',
|
|
55
|
-
algorithm: 'gzip',
|
|
56
|
-
test: /\.js$|\.css$$/,
|
|
57
|
-
// we are compressing all files since in aws cloudfront edge lambda, we don't want to whitelist files that are not compressed due to below limits
|
|
58
|
-
minRatio: Number.MAX_SAFE_INTEGER,
|
|
59
|
-
});
|
|
60
|
-
|
|
61
53
|
const getModulePreRules = () => [
|
|
62
54
|
{
|
|
63
55
|
test: /\.(jpe?g|png|gif|svg|ico)$/,
|
|
@@ -150,7 +142,7 @@ exports.webpackFinal = async (config, { configType }) => {
|
|
|
150
142
|
|
|
151
143
|
config.plugins.push(...getAdditionalPlugins());
|
|
152
144
|
if (isProd) {
|
|
153
|
-
config.plugins.
|
|
145
|
+
config.plugins = config.plugins.concat(getCompressionPlugins());
|
|
154
146
|
}
|
|
155
147
|
|
|
156
148
|
config.resolve.alias = { ...config.resolve.alias, ...getAlias() };
|
|
@@ -168,7 +160,7 @@ exports.webpackFinal = async (config, { configType }) => {
|
|
|
168
160
|
|
|
169
161
|
// storybook manager webpack
|
|
170
162
|
exports.managerWebpack = async (config) => {
|
|
171
|
-
config.plugins.
|
|
163
|
+
config.plugins = config.plugins.concat(getCompressionPlugins());
|
|
172
164
|
config.resolve.alias = { ...config.resolve.alias, ...getAlias() };
|
|
173
165
|
return config;
|
|
174
166
|
};
|