@elliemae/pui-cli 6.0.0-beta.14 → 6.0.0-beta.15

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.
@@ -60,12 +60,20 @@ const customHost = argv.host || process.env.HOST;
60
60
  const host = customHost || null; // Let http.Server use its default IPv6/4 host
61
61
  const prettyHost = customHost || 'localhost';
62
62
 
63
- // use the gzipped bundle
64
- app.get('*.js', (req, res, next) => {
65
- req.url += '.gz';
66
- res.set('Content-Encoding', 'gzip');
63
+ const serveCompressedAssets = (req, res, next) => {
64
+ if (req.header('Accept-Encoding').includes('br')) {
65
+ req.url += '.br';
66
+ res.set('Content-Encoding', 'br');
67
+ } else {
68
+ req.url += '.gz';
69
+ res.set('Content-Encoding', 'gzip');
70
+ }
67
71
  next();
68
- });
72
+ };
73
+
74
+ // use the compressed bundle
75
+ app.get('*.js', serveCompressedAssets);
76
+ app.get('*.css', serveCompressedAssets);
69
77
 
70
78
  // Start your app.
71
79
  app.listen(port, host, async (err) => {
@@ -2,6 +2,8 @@
2
2
  const path = require('path');
3
3
  const fs = require('fs');
4
4
  const _ = require('lodash');
5
+ const CompressionPlugin = require('compression-webpack-plugin');
6
+ const zlib = require('zlib');
5
7
 
6
8
  let pathSep = path.sep;
7
9
  if (pathSep === '\\')
@@ -184,6 +186,38 @@ const isGoogleTagManagerEnabled = () => {
184
186
  return !!appConfig?.googleTagManager;
185
187
  };
186
188
 
189
+ const getCompressionPlugins = () => {
190
+ const commonConfig = {
191
+ test: /\.(js|css|html|svg)$/,
192
+ exclude: [
193
+ /\/adrum-ext/,
194
+ /\/emuiUserMonitoring/,
195
+ /\/emuiDiagnostics/,
196
+ /\/emuiAppLoader/,
197
+ /\/encwLoader/,
198
+ ],
199
+ // 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
200
+ minRatio: Number.MAX_SAFE_INTEGER,
201
+ };
202
+ return [
203
+ new CompressionPlugin({
204
+ filename: '[path][base].gz',
205
+ algorithm: 'gzip',
206
+ ...commonConfig,
207
+ }),
208
+ new CompressionPlugin({
209
+ filename: '[path][base].br',
210
+ algorithm: 'brotliCompress',
211
+ ...commonConfig,
212
+ compressionOptions: {
213
+ params: {
214
+ [zlib.constants.BROTLI_PARAM_QUALITY]: 11,
215
+ },
216
+ },
217
+ }),
218
+ ];
219
+ };
220
+
187
221
  exports.excludeNodeModulesExcept = excludeNodeModulesExcept;
188
222
  exports.getLibraryName = getLibraryName;
189
223
  exports.getAppConfig = getAppConfig;
@@ -208,3 +242,4 @@ exports.resolveExtensions = [
208
242
  ];
209
243
  exports.mainFields = ['browser', 'module', 'main'];
210
244
  exports.isGoogleTagManagerEnabled = isGoogleTagManagerEnabled;
245
+ exports.getCompressionPlugins = getCompressionPlugins;
@@ -1,10 +1,9 @@
1
1
  const path = require('path');
2
- const CompressionPlugin = require('compression-webpack-plugin');
3
2
  const MiniCssExtractPlugin = require('mini-css-extract-plugin');
4
3
  const HtmlWebpackPlugin = require('html-webpack-plugin');
5
4
  const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
6
5
  const { ESBuildMinifyPlugin } = require('esbuild-loader');
7
- const { getLibraryName } = require('./helpers');
6
+ const { getLibraryName, getCompressionPlugins } = require('./helpers');
8
7
  const { ESBUILD_TARGET } = require('../esbuild');
9
8
 
10
9
  const libraryName = getLibraryName();
@@ -62,13 +61,7 @@ module.exports = require('./webpack.lib.base.babel')({
62
61
  chunkFilename: `css/${libraryName}.[contenthash].chunk.css`,
63
62
  }),
64
63
 
65
- new CompressionPlugin({
66
- filename: '[path][base].gz',
67
- algorithm: 'gzip',
68
- test: /\.js$|\.css$$/,
69
- // 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
70
- minRatio: Number.MAX_SAFE_INTEGER,
71
- }),
64
+ ...getCompressionPlugins(),
72
65
 
73
66
  new BundleAnalyzerPlugin({
74
67
  analyzerMode: 'static',
@@ -2,7 +2,6 @@
2
2
  const path = require('path');
3
3
  const HtmlWebpackPlugin = require('html-webpack-plugin');
4
4
  const { GenerateSW } = require('workbox-webpack-plugin');
5
- const CompressionPlugin = require('compression-webpack-plugin');
6
5
  const MiniCssExtractPlugin = require('mini-css-extract-plugin');
7
6
  const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
8
7
  const { ESBuildMinifyPlugin } = require('esbuild-loader');
@@ -15,6 +14,7 @@ const {
15
14
  getPaths,
16
15
  getAppVersion,
17
16
  isGoogleTagManagerEnabled,
17
+ getCompressionPlugins,
18
18
  } = require('./helpers');
19
19
  const { ESBUILD_TARGET } = require('../esbuild');
20
20
 
@@ -68,20 +68,7 @@ const getProdConfig = ({ latestVersion = true } = {}) => {
68
68
  chunkFilename: 'css/[name].[contenthash].chunk.css',
69
69
  }),
70
70
 
71
- new CompressionPlugin({
72
- filename: '[path][base].gz',
73
- algorithm: 'gzip',
74
- test: /\.js$|\.css$$/,
75
- exclude: [
76
- /\/adrum-ext/,
77
- /\/emuiUserMonitoring/,
78
- /\/emuiDiagnostics/,
79
- /\/emuiAppLoader/,
80
- /\/encwLoader/,
81
- ],
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
- }),
71
+ ...getCompressionPlugins(),
85
72
 
86
73
  new BundleAnalyzerPlugin({
87
74
  analyzerMode: 'static',
@@ -1,13 +1,11 @@
1
- /* eslint-disable max-lines */
2
1
  const webpack = require('webpack');
3
2
  const MiniCssExtractPlugin = require('mini-css-extract-plugin');
4
3
  const CopyWebpackPlugin = require('copy-webpack-plugin');
5
- const CompressionPlugin = require('compression-webpack-plugin');
6
4
  const {
7
5
  getAppConfig,
8
6
  isApp,
9
7
  getAlias,
10
- excludeNodeModulesExcept,
8
+ getCompressionPlugins,
11
9
  } = require('./helpers');
12
10
 
13
11
  const IS_APP = isApp();
@@ -45,30 +43,7 @@ const getAdditionalPlugins = () => [
45
43
  }),
46
44
  ];
47
45
 
48
- const compressionPlugin = new CompressionPlugin({
49
- filename: '[path][base].gz',
50
- algorithm: 'gzip',
51
- test: /\.js$|\.css$$/,
52
- // 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
53
- minRatio: Number.MAX_SAFE_INTEGER,
54
- });
55
-
56
46
  const getModulePreRules = () => [
57
- {
58
- test: /\.(jpe?g|png|gif|svg|ico)$/,
59
- use: [
60
- 'file-loader',
61
- {
62
- loader: 'image-webpack-loader',
63
- options: {
64
- gifsicle: {
65
- enabled: false,
66
- },
67
- },
68
- },
69
- ],
70
- enforce: 'pre',
71
- },
72
47
  {
73
48
  test: /\.(js|ts|jsx|tsx)$/,
74
49
  enforce: 'pre',
@@ -88,45 +63,12 @@ const getModulePreRules = () => [
88
63
  },
89
64
  ];
90
65
 
91
- const getModuleRules = () => [
92
- {
93
- test: /\.(woff|woff2)$/,
94
- exclude: excludeNodeModulesExcept(['@elliemae/*']),
95
- type: 'asset/resource',
96
- },
97
- {
98
- type: 'asset',
99
- resourceQuery: /url/, // *.svg?react
100
- },
101
- {
102
- test: /\.svg$/i,
103
- issuer: /\.[jt]sx?$/,
104
- use: ['@svgr/webpack'],
105
- },
106
- {
107
- test: /\.(jpe?g|png|gif|ico)$/i,
108
- exclude: excludeNodeModulesExcept(['@elliemae/*']),
109
- type: 'asset',
110
- },
111
- {
112
- test: /\.(mp4|webm)$/,
113
- exclude: excludeNodeModulesExcept(['@elliemae/*']),
114
- type: 'asset',
115
- },
116
- ];
117
-
118
66
  exports.webpackFinal = async (config, { configType }) => {
119
67
  const isProd = configType === 'PRODUCTION';
120
- // remove asset processing that comes with storybook webpack, we will use ours
121
- config.module.rules = config.module.rules.filter(
122
- ({ type }) => type !== 'asset/resource',
123
- );
124
68
  config.module.rules.push(...getModulePreRules());
125
- config.module.rules.unshift(...getModuleRules(isProd));
126
-
127
69
  config.plugins.push(...getAdditionalPlugins());
128
70
  if (isProd) {
129
- config.plugins.push(compressionPlugin);
71
+ config.plugins = config.plugins.concat(getCompressionPlugins());
130
72
  }
131
73
 
132
74
  config.resolve.alias = { ...config.resolve.alias, ...getAlias() };
@@ -141,7 +83,7 @@ exports.webpackFinal = async (config, { configType }) => {
141
83
 
142
84
  // storybook manager webpack
143
85
  exports.managerWebpack = async (config) => {
144
- config.plugins.push(compressionPlugin);
86
+ config.plugins = config.plugins.concat(getCompressionPlugins());
145
87
  config.resolve.alias = { ...config.resolve.alias, ...getAlias() };
146
88
  return config;
147
89
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elliemae/pui-cli",
3
- "version": "6.0.0-beta.14",
3
+ "version": "6.0.0-beta.15",
4
4
  "private": false,
5
5
  "description": "EllieMae Platform UI CLI",
6
6
  "sideEffects": false,
@@ -148,7 +148,7 @@
148
148
  "eslint-plugin-react": "~7.27.1",
149
149
  "eslint-plugin-react-hooks": "~4.3.0",
150
150
  "eslint-plugin-redux-saga": "~1.2.1",
151
- "eslint-plugin-storybook": "~0.5.1",
151
+ "eslint-plugin-storybook": "~0.5.2",
152
152
  "eslint-plugin-testing-library": "~5.0.1",
153
153
  "eslint-plugin-wdio": "~7.4.2",
154
154
  "execa": "~5.1.1",