@elliemae/pui-cli 6.0.0-beta.13 → 6.0.0-beta.17

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/esbuild.js CHANGED
@@ -1,5 +1,6 @@
1
1
  const esbuild = require('esbuild');
2
2
  const fg = require('fast-glob');
3
+ const fs = require('fs');
3
4
 
4
5
  const ESBUILD_TARGET = 'es2020';
5
6
 
@@ -10,7 +11,18 @@ const commonConfig = {
10
11
  mainFields: ['module', 'browser', 'main'],
11
12
  };
12
13
 
13
- const outDir = 'dist';
14
+ const distFolder = 'dist';
15
+
16
+ const copyFiles = async ({ srcdir, outdir }) => {
17
+ const files = await fg([
18
+ `${srcdir}/**/*.*`,
19
+ `!${srcdir}/**/*.{js,jsx,ts,tsx,cjs,mjs}`,
20
+ ]);
21
+ files.forEach((srcFilePath) => {
22
+ const destFilePath = srcFilePath.replace(srcdir, outdir);
23
+ fs.copyFileSync(srcFilePath, destFilePath);
24
+ });
25
+ };
14
26
 
15
27
  const build = async ({ srcPath, commonJS }) => {
16
28
  const inputFiles = [
@@ -20,23 +32,27 @@ const build = async ({ srcPath, commonJS }) => {
20
32
  `!${srcPath}/**/*.endpoint.{js,jsx,ts,tsx}`,
21
33
  ];
22
34
  if (!commonJS) {
35
+ const outdir = `${distFolder}/es`;
23
36
  const entryPoints = await fg(inputFiles);
24
37
  await esbuild.build({
25
38
  entryPoints,
26
39
  ...commonConfig,
27
- outdir: `${outDir}/es`,
40
+ outdir,
28
41
  format: 'esm',
29
42
  });
43
+ await copyFiles({ srcdir: srcPath, outdir });
30
44
  } else {
45
+ const outdir = `${distFolder}/cjs`;
31
46
  const commonJSEntryPoints = await fg(
32
47
  inputFiles.concat([`${srcPath}/**/*.cjs`]),
33
48
  );
34
49
  await esbuild.build({
35
50
  entryPoints: commonJSEntryPoints,
36
51
  ...commonConfig,
37
- outdir: `${outDir}/cjs`,
52
+ outdir,
38
53
  format: 'cjs',
39
54
  });
55
+ await copyFiles({ srcdir: srcPath, outdir });
40
56
  }
41
57
  };
42
58
 
@@ -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;
@@ -7,6 +7,7 @@ const DuplicatePackageCheckerPlugin = require('duplicate-package-checker-webpack
7
7
  const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
8
8
  const MomentLocalesPlugin = require('moment-locales-webpack-plugin');
9
9
  const { WebpackManifestPlugin } = require('webpack-manifest-plugin');
10
+ const FaviconsWebpackPlugin = require('favicons-webpack-plugin');
10
11
  const { ProvidePlugin } = require('webpack');
11
12
 
12
13
  const {
@@ -18,7 +19,6 @@ const {
18
19
  } = require('./helpers');
19
20
  const { ESBUILD_TARGET } = require('../esbuild');
20
21
 
21
- // get the application configuration
22
22
  const minicssLoader = {
23
23
  loader: MiniCssExtractPlugin.loader,
24
24
  options: {},
@@ -31,9 +31,6 @@ const postcssPlugins = [PostcssPresetEnv({ autoprefixer: { grid: true } })];
31
31
  const { buildPath, publicPath } = getPaths();
32
32
 
33
33
  const plugins = [
34
- // Always expose NODE_ENV to webpack, in order to use `process.env.NODE_ENV`
35
- // inside your code for any environment checks; Terser will automatically
36
- // drop any unreachable code.
37
34
  new webpack.EnvironmentPlugin({
38
35
  NODE_ENV: 'development',
39
36
  ASSET_PATH: '/',
@@ -44,7 +41,6 @@ const plugins = [
44
41
  APP_CONFIG: getAppConfig(),
45
42
  }),
46
43
  new CaseSensitivePathsPlugin(),
47
- // new ESLintPlugin(),
48
44
  new ProvidePlugin({
49
45
  React: 'react',
50
46
  }),
@@ -104,6 +100,18 @@ const plugins = [
104
100
  new DuplicatePackageCheckerPlugin(),
105
101
  new MomentLocalesPlugin(),
106
102
  new WebpackManifestPlugin(),
103
+ new FaviconsWebpackPlugin({
104
+ logo: './app/view/images/favicon.png',
105
+ manifest: null,
106
+ favicons: {
107
+ developerName: 'ICE MT',
108
+ developerURL: null, // prevent retrieving from the nearest package.json
109
+ icons: {
110
+ coast: false,
111
+ yandex: false,
112
+ },
113
+ },
114
+ }),
107
115
  ];
108
116
 
109
117
  module.exports = (options) => ({
@@ -111,7 +119,6 @@ module.exports = (options) => ({
111
119
  entry: options.entry,
112
120
  output: {
113
121
  clean: true,
114
- // Compile into js/build.js
115
122
  path: buildPath,
116
123
  publicPath,
117
124
  ...options.output,
@@ -120,7 +127,7 @@ module.exports = (options) => ({
120
127
  module: {
121
128
  rules: [
122
129
  {
123
- test: /\.(jpe?g|png|gif|svg|ico)$/,
130
+ test: /\.(jpe?g|png|gif|ico)$/,
124
131
  use: [
125
132
  'file-loader',
126
133
  {
@@ -213,10 +220,6 @@ module.exports = (options) => ({
213
220
  exclude: excludeNodeModulesExcept(['@elliemae/*']),
214
221
  type: 'asset/resource',
215
222
  },
216
- {
217
- type: 'asset',
218
- resourceQuery: /url/, // *.svg?react
219
- },
220
223
  {
221
224
  test: /\.svg$/i,
222
225
  issuer: /\.[jt]sx?$/,
@@ -236,6 +239,10 @@ module.exports = (options) => ({
236
239
  resourceQuery: /resource/,
237
240
  type: 'asset/resource',
238
241
  },
242
+ {
243
+ type: 'asset',
244
+ resourceQuery: /url/,
245
+ },
239
246
  ],
240
247
  },
241
248
  plugins: plugins.concat(options.plugins),
@@ -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
- 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
- },
46
+ const getModuleRules = () => [
72
47
  {
73
48
  test: /\.(js|ts|jsx|tsx)$/,
74
49
  enforce: 'pre',
@@ -86,52 +61,32 @@ const getModulePreRules = () => [
86
61
  },
87
62
  ],
88
63
  },
89
- ];
90
-
91
- const getModuleRules = () => [
92
- {
93
- test: /\.(woff|woff2)$/,
94
- exclude: excludeNodeModulesExcept(['@elliemae/*']),
95
- type: 'asset/resource',
96
- },
97
64
  {
98
65
  type: 'asset',
99
- resourceQuery: /url/, // *.svg?react
66
+ resourceQuery: /url/,
100
67
  },
101
68
  {
102
69
  test: /\.svg$/i,
103
70
  issuer: /\.[jt]sx?$/,
104
71
  use: ['@svgr/webpack'],
105
72
  },
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
73
  ];
117
74
 
118
75
  exports.webpackFinal = async (config, { configType }) => {
119
76
  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',
77
+ const fileLoaderRule = config.module.rules.find((rule) =>
78
+ rule.test?.test?.('.svg'),
123
79
  );
124
- config.module.rules.push(...getModulePreRules());
125
- config.module.rules.unshift(...getModuleRules(isProd));
126
-
80
+ fileLoaderRule.exclude = /\.svg$/i;
81
+ config.module.rules.unshift(...getModuleRules());
127
82
  config.plugins.push(...getAdditionalPlugins());
128
83
  if (isProd) {
129
- config.plugins.push(compressionPlugin);
84
+ config.plugins = config.plugins.concat(getCompressionPlugins());
130
85
  }
131
86
 
132
87
  config.resolve.alias = { ...config.resolve.alias, ...getAlias() };
133
88
  config.resolve.fallback = { ...config.resolve.fallback, crypto: false };
134
-
89
+ config.resolve.extensions.push('.svg');
135
90
  config.externals = config.externals || {};
136
91
  config.externals['@elliemae/pui-user-monitoring'] = 'emuiUserMonitoring';
137
92
  config.externals['@elliemae/pui-app-loader'] = 'emuiAppLoader';
@@ -141,7 +96,7 @@ exports.webpackFinal = async (config, { configType }) => {
141
96
 
142
97
  // storybook manager webpack
143
98
  exports.managerWebpack = async (config) => {
144
- config.plugins.push(compressionPlugin);
99
+ config.plugins = config.plugins.concat(getCompressionPlugins());
145
100
  config.resolve.alias = { ...config.resolve.alias, ...getAlias() };
146
101
  return config;
147
102
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elliemae/pui-cli",
3
- "version": "6.0.0-beta.13",
3
+ "version": "6.0.0-beta.17",
4
4
  "private": false,
5
5
  "description": "EllieMae Platform UI CLI",
6
6
  "sideEffects": false,
@@ -70,18 +70,18 @@
70
70
  "@semantic-release/changelog": "~6.0.1",
71
71
  "@semantic-release/exec": "~6.0.2",
72
72
  "@semantic-release/git": "~10.0.1",
73
- "@storybook/addon-a11y": "~6.4.3",
74
- "@storybook/addon-essentials": "~6.4.3",
73
+ "@storybook/addon-a11y": "~6.4.4",
74
+ "@storybook/addon-essentials": "~6.4.4",
75
75
  "@storybook/addon-events": "~6.2.9",
76
- "@storybook/addon-interactions": "~6.4.3",
77
- "@storybook/addon-links": "~6.4.3",
78
- "@storybook/addon-storysource": "~6.4.3",
79
- "@storybook/builder-webpack5": "~6.4.3",
80
- "@storybook/manager-webpack5": "~6.4.3",
81
- "@storybook/react": "~6.4.3",
82
- "@storybook/theming": "~6.4.3",
76
+ "@storybook/addon-interactions": "~6.4.4",
77
+ "@storybook/addon-links": "~6.4.4",
78
+ "@storybook/addon-storysource": "~6.4.4",
79
+ "@storybook/builder-webpack5": "~6.4.4",
80
+ "@storybook/manager-webpack5": "~6.4.4",
81
+ "@storybook/react": "~6.4.4",
82
+ "@storybook/theming": "~6.4.4",
83
83
  "@stylelint/postcss-css-in-js": "~0.37.2",
84
- "@svgr/webpack": "~6.0.0",
84
+ "@svgr/webpack": "~6.1.0",
85
85
  "@testing-library/jest-dom": "~5.15.1",
86
86
  "@testing-library/react": "~12.1.2",
87
87
  "@testing-library/react-hooks": "~7.0.2",
@@ -128,6 +128,7 @@
128
128
  "esbuild": "~0.14.1",
129
129
  "esbuild-jest": "~0.5.0",
130
130
  "esbuild-loader": "~2.16.0",
131
+ "esbuild-plugin-svgr": "~0.0.3",
131
132
  "eslint": "~8.3.0",
132
133
  "eslint-config-airbnb": "~18.2.1",
133
134
  "eslint-config-airbnb-base": "~15.0.0",
@@ -148,12 +149,13 @@
148
149
  "eslint-plugin-react": "~7.27.1",
149
150
  "eslint-plugin-react-hooks": "~4.3.0",
150
151
  "eslint-plugin-redux-saga": "~1.2.1",
151
- "eslint-plugin-storybook": "~0.5.1",
152
+ "eslint-plugin-storybook": "~0.5.2",
152
153
  "eslint-plugin-testing-library": "~5.0.1",
153
154
  "eslint-plugin-wdio": "~7.4.2",
154
155
  "execa": "~5.1.1",
155
156
  "express": "~4.17.1",
156
157
  "express-pino-logger": "~7.0.0",
158
+ "favicons-webpack-plugin": "~5.0.2",
157
159
  "file-loader": "~6.2.0",
158
160
  "fork-ts-checker-webpack-plugin": "~6.5.0",
159
161
  "helmet-csp": "~3.4.0",