@elliemae/pui-cli 6.13.0-beta.2 → 7.0.0-beta.2
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/cli-commands/build.js +7 -3
- package/lib/cli-commands/utils.js +48 -2
- package/lib/server/index.js +8 -40
- package/lib/server/middlewares/addProdMiddlewares.js +11 -10
- package/lib/server/middlewares/index.js +37 -0
- package/lib/server/util/index.js +10 -5
- package/lib/testing/jest.config.js +4 -2
- package/lib/webpack/helpers.js +8 -10
- package/lib/webpack/webpack.base.babel.js +17 -9
- package/lib/webpack/webpack.dev.babel.js +0 -2
- package/lib/webpack/webpack.prod.babel.js +11 -31
- package/package.json +13 -13
- package/lib/server/argv.js +0 -1
- package/lib/server/middlewares/frontendMiddleware.js +0 -16
- package/lib/server/port.js +0 -6
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
const { exit } = require('yargs');
|
|
2
|
+
const path = require('path');
|
|
2
3
|
const {
|
|
3
4
|
exec,
|
|
4
5
|
logInfo,
|
|
5
6
|
logError,
|
|
6
7
|
logSuccess,
|
|
7
8
|
writeAppInfo,
|
|
9
|
+
copyBuildAssetsToVersionedFolder,
|
|
8
10
|
} = require('./utils');
|
|
9
11
|
const { esBuild, TARGETS } = require('../transpile/esbuild');
|
|
10
12
|
|
|
11
|
-
const { name } = require('../../package.json');
|
|
12
|
-
|
|
13
13
|
async function buildWebApp() {
|
|
14
14
|
await exec(`rimraf ./build`);
|
|
15
15
|
await exec(
|
|
16
|
-
`cross-env NODE_ENV=production webpack --config
|
|
16
|
+
`cross-env NODE_ENV=production webpack --config ${path.resolve(
|
|
17
|
+
__dirname,
|
|
18
|
+
'../webpack/webpack.prod.babel.js',
|
|
19
|
+
)} --color`,
|
|
17
20
|
);
|
|
21
|
+
await copyBuildAssetsToVersionedFolder();
|
|
18
22
|
await writeAppInfo();
|
|
19
23
|
}
|
|
20
24
|
|
|
@@ -1,9 +1,21 @@
|
|
|
1
|
+
/* eslint-disable max-lines */
|
|
1
2
|
/* eslint-disable no-console */
|
|
2
3
|
const execa = require('execa');
|
|
3
4
|
const chalk = require('chalk');
|
|
4
5
|
const path = require('path');
|
|
5
|
-
const {
|
|
6
|
-
|
|
6
|
+
const {
|
|
7
|
+
readFile,
|
|
8
|
+
writeFile,
|
|
9
|
+
mkdir,
|
|
10
|
+
readdir,
|
|
11
|
+
copyFile,
|
|
12
|
+
} = require('fs/promises');
|
|
13
|
+
const {
|
|
14
|
+
getPaths,
|
|
15
|
+
isAppLoaderEnabled,
|
|
16
|
+
getAppVersion,
|
|
17
|
+
LATEST_VERSION,
|
|
18
|
+
} = require('../webpack/helpers');
|
|
7
19
|
|
|
8
20
|
const browsersMapping = {
|
|
9
21
|
and_chr: 'Chrome for Android',
|
|
@@ -87,3 +99,37 @@ exports.writeAppInfo = async () => {
|
|
|
87
99
|
path.join(process.cwd(), 'build', 'public', 'info.json'),
|
|
88
100
|
].forEach(async (infoPath) => writeFile(infoPath, infoJSON));
|
|
89
101
|
};
|
|
102
|
+
|
|
103
|
+
const copyDir = async (src, dest) => {
|
|
104
|
+
const entries = await readdir(src, {
|
|
105
|
+
withFileTypes: true,
|
|
106
|
+
});
|
|
107
|
+
await mkdir(dest);
|
|
108
|
+
return Promise.all(
|
|
109
|
+
entries.map((entry) => {
|
|
110
|
+
const srcPath = path.join(src, entry.name);
|
|
111
|
+
const destPath = path.join(dest, entry.name);
|
|
112
|
+
if (entry.isDirectory()) {
|
|
113
|
+
return copyDir(srcPath, destPath);
|
|
114
|
+
}
|
|
115
|
+
return copyFile(srcPath, destPath);
|
|
116
|
+
}),
|
|
117
|
+
);
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const updateManifestWithVersionInfo = async (dest) => {
|
|
121
|
+
const manifestFile = path.join(dest, 'manifest.json');
|
|
122
|
+
let manifestData = await readFile(manifestFile, 'utf8');
|
|
123
|
+
manifestData = manifestData.replace(/latest\//g, `${getAppVersion()}/`);
|
|
124
|
+
await writeFile(manifestFile, manifestData);
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
exports.copyBuildAssetsToVersionedFolder = async () => {
|
|
128
|
+
const appVersion = getAppVersion();
|
|
129
|
+
const isVersionedApp = isAppLoaderEnabled() && appVersion !== LATEST_VERSION;
|
|
130
|
+
if (!isVersionedApp) return;
|
|
131
|
+
const src = path.resolve(process.cwd(), 'build/public/latest');
|
|
132
|
+
const dest = path.resolve(process.cwd(), `build/public/${appVersion}`);
|
|
133
|
+
await copyDir(src, dest);
|
|
134
|
+
await updateManifestWithVersionInfo(dest);
|
|
135
|
+
};
|
package/lib/server/index.js
CHANGED
|
@@ -1,26 +1,11 @@
|
|
|
1
1
|
/* eslint consistent-return:0 import/order:0 */
|
|
2
|
-
|
|
3
2
|
const express = require('express');
|
|
4
|
-
const cors = require('cors');
|
|
5
|
-
const { resolve } = require('path');
|
|
6
|
-
const expressPinoLogger = require('express-pino-logger');
|
|
7
|
-
const { csp } = require('./csp');
|
|
8
3
|
const logger = require('./logger');
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const {
|
|
14
|
-
|
|
15
|
-
const pino = expressPinoLogger({
|
|
16
|
-
transport: {
|
|
17
|
-
target: 'pino-pretty',
|
|
18
|
-
options: {
|
|
19
|
-
colorize: true,
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
});
|
|
23
|
-
pino.logger.level = 'warn';
|
|
4
|
+
const {
|
|
5
|
+
setupDefaultMiddlewares,
|
|
6
|
+
setupAdditionalMiddlewars,
|
|
7
|
+
} = require('./middlewares');
|
|
8
|
+
const { loadRoutes, port, host } = require('./util');
|
|
24
9
|
|
|
25
10
|
// const corsOptions = {
|
|
26
11
|
// origin: '*',
|
|
@@ -37,33 +22,16 @@ pino.logger.level = 'warn';
|
|
|
37
22
|
// maxAge: 3600,
|
|
38
23
|
// };
|
|
39
24
|
const app = express();
|
|
40
|
-
app
|
|
41
|
-
app.use(cors());
|
|
42
|
-
app.options('*', cors());
|
|
43
|
-
csp(app);
|
|
44
|
-
app.use(express.urlencoded({ extended: false }));
|
|
45
|
-
app.use(express.text({ type: 'text/plain' }));
|
|
46
|
-
app.use(express.json({ type: 'application/json' }));
|
|
47
|
-
app.use(express.json({ type: 'application/csp-report' }));
|
|
48
|
-
|
|
25
|
+
setupDefaultMiddlewares(app);
|
|
49
26
|
// load all custom routes from the application
|
|
50
27
|
loadRoutes(app);
|
|
51
|
-
|
|
52
28
|
// In production we need to pass these values in instead of relying on webpack
|
|
53
|
-
|
|
54
|
-
outputPath: resolve(process.cwd(), 'build/public'),
|
|
55
|
-
publicPath: getAssetPath(),
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
// get the intended host and port number, use localhost and port 3000 if not provided
|
|
59
|
-
const customHost = argv.host || process.env.HOST;
|
|
60
|
-
const host = customHost || null; // Let http.Server use its default IPv6/4 host
|
|
61
|
-
const prettyHost = customHost || 'localhost';
|
|
29
|
+
setupAdditionalMiddlewars(app);
|
|
62
30
|
|
|
63
31
|
// Start your app.
|
|
64
32
|
app.listen(port, host, async (err) => {
|
|
65
33
|
if (err) {
|
|
66
34
|
return logger.error(err.message);
|
|
67
35
|
}
|
|
68
|
-
logger.appStarted(port,
|
|
36
|
+
logger.appStarted(port, host || 'localhost');
|
|
69
37
|
});
|
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
const path = require('path');
|
|
2
1
|
const compression = require('compression');
|
|
3
2
|
const expressStaticGzip = require('express-static-gzip');
|
|
4
3
|
const { sendFileWithCSPNonce } = require('../csp');
|
|
4
|
+
const { getPaths } = require('../webpack/helpers');
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
const publicPath = options.publicPath || '/';
|
|
8
|
-
const outputPath =
|
|
9
|
-
options.outputPath || path.resolve(process.cwd(), 'build/public');
|
|
6
|
+
const paths = getPaths();
|
|
10
7
|
|
|
8
|
+
module.exports = function addProdMiddlewares(
|
|
9
|
+
app,
|
|
10
|
+
{ buildPath = paths.buildPath, mountPath = paths.mountPath },
|
|
11
|
+
) {
|
|
11
12
|
// compression middleware compresses your server responses which makes them
|
|
12
13
|
// smaller (applies also to assets). You can read more about that technique
|
|
13
14
|
// and other good practices on official Express.js docs http://mxs.is/googmy
|
|
14
15
|
app.use(compression());
|
|
15
16
|
|
|
16
|
-
app.get(
|
|
17
|
-
sendFileWithCSPNonce({
|
|
17
|
+
app.get(mountPath, (req, res) => {
|
|
18
|
+
sendFileWithCSPNonce({ buildPath, res });
|
|
18
19
|
});
|
|
19
20
|
|
|
20
21
|
app.use(
|
|
21
|
-
|
|
22
|
-
expressStaticGzip(
|
|
22
|
+
mountPath,
|
|
23
|
+
expressStaticGzip(buildPath, {
|
|
23
24
|
index: false,
|
|
24
25
|
enableBrotli: true,
|
|
25
26
|
orderPreference: ['br'],
|
|
@@ -27,5 +28,5 @@ module.exports = function addProdMiddlewares(app, options) {
|
|
|
27
28
|
);
|
|
28
29
|
app.use(expressStaticGzip('cdn'));
|
|
29
30
|
|
|
30
|
-
app.get('*', (req, res) => sendFileWithCSPNonce({
|
|
31
|
+
app.get('*', (req, res) => sendFileWithCSPNonce({ buildPath, res }));
|
|
31
32
|
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const express = require('express');
|
|
2
|
+
const cors = require('cors');
|
|
3
|
+
const expressPinoLogger = require('express-pino-logger');
|
|
4
|
+
const { csp } = require('./csp');
|
|
5
|
+
const addProdMiddlewares = require('./addProdMiddlewares');
|
|
6
|
+
const addDevMiddlewares = require('./addDevMiddlewares');
|
|
7
|
+
const webpackConfig = require('../../webpack/webpack.dev.babel');
|
|
8
|
+
|
|
9
|
+
exports.setupDefaultMiddlewares = (app) => {
|
|
10
|
+
const pino = expressPinoLogger({
|
|
11
|
+
transport: {
|
|
12
|
+
target: 'pino-pretty',
|
|
13
|
+
options: {
|
|
14
|
+
colorize: true,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
pino.logger.level = 'warn';
|
|
19
|
+
app.use(pino);
|
|
20
|
+
app.use(cors());
|
|
21
|
+
app.options('*', cors());
|
|
22
|
+
csp(app);
|
|
23
|
+
app.use(express.urlencoded({ extended: false }));
|
|
24
|
+
app.use(express.text({ type: 'text/plain' }));
|
|
25
|
+
app.use(express.json({ type: 'application/json' }));
|
|
26
|
+
app.use(express.json({ type: 'application/csp-report' }));
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
exports.setupAdditionalMiddlewars = (app, options) => {
|
|
30
|
+
const isProd = process.env.NODE_ENV === 'production';
|
|
31
|
+
if (isProd) {
|
|
32
|
+
addProdMiddlewares(app, options);
|
|
33
|
+
} else {
|
|
34
|
+
addDevMiddlewares(app, webpackConfig);
|
|
35
|
+
}
|
|
36
|
+
return app;
|
|
37
|
+
};
|
package/lib/server/util/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
|
+
const argv = require('minimist')(process.argv.slice(2));
|
|
3
4
|
|
|
4
5
|
const getCWD = () => process.cwd();
|
|
5
6
|
|
|
@@ -25,7 +26,7 @@ const getFilesMatching = (filePattern) => {
|
|
|
25
26
|
const getServerRouteFiles = getFilesMatching(allJS);
|
|
26
27
|
const getServiceEndpoints = getFilesMatching(serviceEndpoints);
|
|
27
28
|
|
|
28
|
-
|
|
29
|
+
exports.loadRoutes = (app) => {
|
|
29
30
|
const routeFiles = getServerRouteFiles(path.join(getCWD(), 'server/routes'));
|
|
30
31
|
routeFiles.push(...getServiceEndpoints(path.join(getCWD(), 'app')));
|
|
31
32
|
routeFiles.push(...getServiceEndpoints(path.join(getCWD(), 'lib')));
|
|
@@ -41,7 +42,11 @@ const loadRoutes = (app) => {
|
|
|
41
42
|
});
|
|
42
43
|
};
|
|
43
44
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
exports.port = parseInt(
|
|
46
|
+
argv.port || process.env.port || process.env.PORT || '3000',
|
|
47
|
+
10,
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
exports.host = argv.host || process.env.HOST;
|
|
51
|
+
|
|
52
|
+
exports.getCWD = getCWD;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
const normalizePath = require('normalize-path');
|
|
3
|
-
const { getAppConfig,
|
|
3
|
+
const { getAppConfig, getPaths } = require('../webpack/helpers');
|
|
4
4
|
const swcrcConfig = require('../transpile/swcrc.config.js');
|
|
5
5
|
const { findMonoRepoRoot } = require('../monorepo/utils');
|
|
6
6
|
|
|
7
|
+
const { mountPath } = getPaths();
|
|
8
|
+
|
|
7
9
|
let isReactModule = true;
|
|
8
10
|
try {
|
|
9
11
|
/* eslint-disable global-require, import/no-unresolved */
|
|
@@ -89,7 +91,7 @@ const jestConfig = {
|
|
|
89
91
|
APP_CONFIG: getAppConfig(),
|
|
90
92
|
__webpack_public_path__: '/',
|
|
91
93
|
},
|
|
92
|
-
testURL: `http://localhost:3111${
|
|
94
|
+
testURL: `http://localhost:3111${mountPath}`,
|
|
93
95
|
testEnvironment: 'jsdom',
|
|
94
96
|
};
|
|
95
97
|
|
package/lib/webpack/helpers.js
CHANGED
|
@@ -150,8 +150,6 @@ const getENCWLoaderFileName = () => {
|
|
|
150
150
|
)[0];
|
|
151
151
|
};
|
|
152
152
|
|
|
153
|
-
const getAssetPath = () => (process.env.ASSET_PATH || '/').replace(/\/?$/, '/');
|
|
154
|
-
|
|
155
153
|
const getAppVersion = () => {
|
|
156
154
|
if (!process.env.APP_VERSION) return LATEST_VERSION;
|
|
157
155
|
const match = process.env.APP_VERSION.match(/^v?(\d+\.\d+)\..*$/);
|
|
@@ -165,14 +163,14 @@ const getPaths = (latestVersion = true) => {
|
|
|
165
163
|
process.env.PUI_PIPELINE !== 'true' ? `?timeStamp=${Date.now()}` : '';
|
|
166
164
|
return {
|
|
167
165
|
appVersion: version,
|
|
168
|
-
buildPath: path.resolve(process.cwd(), `build/public
|
|
169
|
-
|
|
166
|
+
buildPath: path.resolve(process.cwd(), `build/public/`),
|
|
167
|
+
mountPath: (process.env.MOUNT_PATH || '/').replace(/\/?$/, '/'),
|
|
170
168
|
publicPath,
|
|
171
|
-
userMonScriptPath:
|
|
172
|
-
appLoaderScriptPath:
|
|
173
|
-
diagnosticsScriptPath:
|
|
174
|
-
globalScriptPath:
|
|
175
|
-
encwLoaderScriptPath:
|
|
169
|
+
userMonScriptPath: `latest/js/${getUserMonitoringFileName()}`,
|
|
170
|
+
appLoaderScriptPath: `latest/js/${getAppLoaderFileName()}`,
|
|
171
|
+
diagnosticsScriptPath: `latest/js/${getDiagnosticsFileName()}`,
|
|
172
|
+
globalScriptPath: `latest/js/global.js${timeStampQuery}`,
|
|
173
|
+
encwLoaderScriptPath: `latest/js/${getENCWLoaderFileName()}`,
|
|
176
174
|
};
|
|
177
175
|
};
|
|
178
176
|
|
|
@@ -226,11 +224,11 @@ const filterByFilePresence = (patterns) =>
|
|
|
226
224
|
!noErrorOnMissing || fs.existsSync(path.resolve(process.cwd(), from)),
|
|
227
225
|
);
|
|
228
226
|
|
|
227
|
+
exports.LATEST_VERSION = LATEST_VERSION;
|
|
229
228
|
exports.excludeNodeModulesExcept = excludeNodeModulesExcept;
|
|
230
229
|
exports.getLibraryName = getLibraryName;
|
|
231
230
|
exports.getAppConfig = getAppConfig;
|
|
232
231
|
exports.mapToFolder = mapToFolder;
|
|
233
|
-
exports.getAssetPath = getAssetPath;
|
|
234
232
|
exports.isApp = isApp;
|
|
235
233
|
exports.getAlias = getAlias;
|
|
236
234
|
exports.getAppVersion = getAppVersion;
|
|
@@ -48,46 +48,47 @@ const plugins = [
|
|
|
48
48
|
patterns: filterByFilePresence([
|
|
49
49
|
{
|
|
50
50
|
from: 'app/app.config.json',
|
|
51
|
-
to: 'app.config.json',
|
|
51
|
+
to: './latest/app.config.json',
|
|
52
52
|
},
|
|
53
53
|
{
|
|
54
54
|
from: 'app/robots.txt',
|
|
55
|
-
to: '
|
|
55
|
+
to: 'robots.txt',
|
|
56
56
|
noErrorOnMissing: true,
|
|
57
57
|
},
|
|
58
58
|
{
|
|
59
59
|
from: 'app/global*.js',
|
|
60
|
-
to: 'js/[name][ext]',
|
|
60
|
+
to: './latest/js/[name][ext]',
|
|
61
61
|
},
|
|
62
62
|
{
|
|
63
63
|
from: 'node_modules/@elliemae/pui-user-monitoring/dist/public/js',
|
|
64
|
-
to: 'js',
|
|
64
|
+
to: './latest/js',
|
|
65
65
|
toType: 'dir',
|
|
66
66
|
info: { minimized: true },
|
|
67
67
|
},
|
|
68
68
|
{
|
|
69
69
|
from: 'node_modules/@elliemae/pui-app-loader/dist/public/js',
|
|
70
|
-
to: 'js',
|
|
70
|
+
to: './latest/js',
|
|
71
71
|
toType: 'dir',
|
|
72
72
|
noErrorOnMissing: true,
|
|
73
73
|
info: { minimized: true },
|
|
74
74
|
},
|
|
75
75
|
{
|
|
76
76
|
from: 'node_modules/@elliemae/encw-loader/dist/public/js',
|
|
77
|
-
to: 'js',
|
|
77
|
+
to: './latest/js',
|
|
78
78
|
toType: 'dir',
|
|
79
79
|
noErrorOnMissing: true,
|
|
80
80
|
info: { minimized: true },
|
|
81
81
|
},
|
|
82
82
|
{
|
|
83
83
|
from: 'node_modules/@elliemae/pui-diagnostics/dist/public/js',
|
|
84
|
-
to: 'js',
|
|
84
|
+
to: './latest/js',
|
|
85
85
|
toType: 'dir',
|
|
86
86
|
noErrorOnMissing: true,
|
|
87
87
|
info: { minimized: true },
|
|
88
88
|
},
|
|
89
89
|
{
|
|
90
90
|
from: 'public',
|
|
91
|
+
to: './latest',
|
|
91
92
|
noErrorOnMissing: true,
|
|
92
93
|
globOptions: {
|
|
93
94
|
ignore: ['readme.md'],
|
|
@@ -95,7 +96,6 @@ const plugins = [
|
|
|
95
96
|
},
|
|
96
97
|
{
|
|
97
98
|
from: 'webroot',
|
|
98
|
-
to: '../',
|
|
99
99
|
noErrorOnMissing: true,
|
|
100
100
|
globOptions: {
|
|
101
101
|
ignore: ['readme.md'],
|
|
@@ -105,8 +105,16 @@ const plugins = [
|
|
|
105
105
|
}),
|
|
106
106
|
new DuplicatePackageCheckerPlugin(),
|
|
107
107
|
new MomentLocalesPlugin({ localesToKeep: ['es-us'] }),
|
|
108
|
-
new WebpackManifestPlugin(
|
|
108
|
+
new WebpackManifestPlugin({
|
|
109
|
+
fileName: './latest/manifest.json',
|
|
110
|
+
publicPath: '',
|
|
111
|
+
map: (file) => {
|
|
112
|
+
file.name = file.name.replace(/^latest\//, '');
|
|
113
|
+
return file;
|
|
114
|
+
},
|
|
115
|
+
}),
|
|
109
116
|
new FaviconsWebpackPlugin({
|
|
117
|
+
outputPath: './latest/assets',
|
|
110
118
|
logo: './app/view/images/favicon.png',
|
|
111
119
|
favicons: {
|
|
112
120
|
developerName: 'ICE MT',
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
-
const { HotModuleReplacementPlugin } = require('webpack');
|
|
3
2
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
4
3
|
const CircularDependencyPlugin = require('circular-dependency-plugin');
|
|
5
4
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
@@ -109,7 +108,6 @@ const devConfig = {
|
|
|
109
108
|
|
|
110
109
|
const config = smp.wrap(baseConfigFactory(devConfig));
|
|
111
110
|
config.plugins = config.plugins.concat([
|
|
112
|
-
new HotModuleReplacementPlugin(),
|
|
113
111
|
new ReactRefreshWebpackPlugin({
|
|
114
112
|
overlay: {
|
|
115
113
|
sockIntegration: 'whm',
|
|
@@ -11,9 +11,7 @@ const browserslistToEsbuild = require('browserslist-to-esbuild');
|
|
|
11
11
|
const baseConfigFactory = require('./webpack.base.babel');
|
|
12
12
|
const {
|
|
13
13
|
isAppLoaderEnabled,
|
|
14
|
-
LATEST_VERSION,
|
|
15
14
|
getPaths,
|
|
16
|
-
getAppVersion,
|
|
17
15
|
isGoogleTagManagerEnabled,
|
|
18
16
|
getCompressionPlugins,
|
|
19
17
|
} = require('./helpers');
|
|
@@ -32,9 +30,9 @@ const getProdConfig = ({ latestVersion = true } = {}) => {
|
|
|
32
30
|
output: {
|
|
33
31
|
path: buildPath,
|
|
34
32
|
publicPath: 'auto',
|
|
35
|
-
filename: 'js/[name].[contenthash].js',
|
|
36
|
-
chunkFilename: 'js/[name].[contenthash].chunk.js',
|
|
37
|
-
assetModuleFilename: 'assets/[name].[hash][ext][query]',
|
|
33
|
+
filename: 'latest/js/[name].[contenthash].js',
|
|
34
|
+
chunkFilename: 'latest/js/[name].[contenthash].chunk.js',
|
|
35
|
+
assetModuleFilename: 'latest/assets/[name].[hash][ext][query]',
|
|
38
36
|
},
|
|
39
37
|
|
|
40
38
|
optimization: {
|
|
@@ -63,11 +61,6 @@ const getProdConfig = ({ latestVersion = true } = {}) => {
|
|
|
63
61
|
},
|
|
64
62
|
|
|
65
63
|
plugins: [
|
|
66
|
-
// new MiniCssExtractPlugin({
|
|
67
|
-
// filename: 'css/[name].[contenthash].css',
|
|
68
|
-
// chunkFilename: 'css/[name].[contenthash].chunk.css',
|
|
69
|
-
// }),
|
|
70
|
-
|
|
71
64
|
...getCompressionPlugins(),
|
|
72
65
|
|
|
73
66
|
new BundleAnalyzerPlugin({
|
|
@@ -77,7 +70,7 @@ const getProdConfig = ({ latestVersion = true } = {}) => {
|
|
|
77
70
|
}),
|
|
78
71
|
|
|
79
72
|
new GenerateSW({
|
|
80
|
-
swDest: '
|
|
73
|
+
swDest: 'sw.js',
|
|
81
74
|
clientsClaim: true,
|
|
82
75
|
skipWaiting: true,
|
|
83
76
|
}),
|
|
@@ -100,7 +93,6 @@ const {
|
|
|
100
93
|
encwLoaderScriptPath,
|
|
101
94
|
} = getPaths();
|
|
102
95
|
const htmlWebpackPlugin = new HtmlWebpackPlugin({
|
|
103
|
-
filename: '../index.html',
|
|
104
96
|
inject: !isAppLoaderEnabled(),
|
|
105
97
|
template: !isAppLoaderEnabled()
|
|
106
98
|
? 'app/index.html'
|
|
@@ -128,33 +120,21 @@ const htmlWebpackPlugin = new HtmlWebpackPlugin({
|
|
|
128
120
|
},
|
|
129
121
|
});
|
|
130
122
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
isAppLoaderEnabled() && getAppVersion() !== LATEST_VERSION;
|
|
134
|
-
|
|
135
|
-
const latestVersionConfig = baseConfigFactory(getProdConfig());
|
|
136
|
-
latestVersionConfig.plugins.push(htmlWebpackPlugin);
|
|
123
|
+
const config = baseConfigFactory(getProdConfig());
|
|
124
|
+
config.plugins.push(htmlWebpackPlugin);
|
|
137
125
|
|
|
138
|
-
const
|
|
139
|
-
getProdConfig({ latestVersion: false }),
|
|
140
|
-
);
|
|
141
|
-
|
|
142
|
-
const addSMPPlugin = (config) => {
|
|
126
|
+
const addSMPPlugin = (webpackConfig) => {
|
|
143
127
|
const smpConfig = new SpeedMeasurePlugin({
|
|
144
128
|
disable: !process.env.MEASURE,
|
|
145
|
-
}).wrap(
|
|
129
|
+
}).wrap(webpackConfig);
|
|
146
130
|
// mini css extract plugin is not working fine with smp
|
|
147
131
|
smpConfig.plugins.push(
|
|
148
132
|
new MiniCssExtractPlugin({
|
|
149
|
-
filename: 'css/[name].[contenthash].css',
|
|
150
|
-
chunkFilename: 'css/[name].[contenthash].chunk.css',
|
|
133
|
+
filename: 'latest/css/[name].[contenthash].css',
|
|
134
|
+
chunkFilename: 'latest/css/[name].[contenthash].chunk.css',
|
|
151
135
|
}),
|
|
152
136
|
);
|
|
153
137
|
return smpConfig;
|
|
154
138
|
};
|
|
155
139
|
|
|
156
|
-
|
|
157
|
-
? [latestVersionConfig, appVersionConfig].map(addSMPPlugin)
|
|
158
|
-
: addSMPPlugin(latestVersionConfig);
|
|
159
|
-
|
|
160
|
-
module.exports = config;
|
|
140
|
+
module.exports = addSMPPlugin(config);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/pui-cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0-beta.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "ICE MT UI Platform CLI",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -67,9 +67,9 @@
|
|
|
67
67
|
"@commitlint/config-conventional": "~16.2.1",
|
|
68
68
|
"@elliemae/browserslist-config-elliemae-latest-browsers": "~1.3.0",
|
|
69
69
|
"@faker-js/faker": "6.0.0",
|
|
70
|
-
"@nrwl/cli": "13.9.
|
|
71
|
-
"@nrwl/tao": "13.9.
|
|
72
|
-
"@nrwl/workspace": "13.9.
|
|
70
|
+
"@nrwl/cli": "13.9.3",
|
|
71
|
+
"@nrwl/tao": "13.9.3",
|
|
72
|
+
"@nrwl/workspace": "13.9.3",
|
|
73
73
|
"@pmmmwh/react-refresh-webpack-plugin": "~0.5.4",
|
|
74
74
|
"@semantic-release/changelog": "~6.0.1",
|
|
75
75
|
"@semantic-release/exec": "~6.0.3",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"@stylelint/postcss-css-in-js": "~0.37.2",
|
|
88
88
|
"@svgr/webpack": "~6.2.1",
|
|
89
89
|
"@swc/cli": "~0.1.55",
|
|
90
|
-
"@swc/core": "~1.2.
|
|
90
|
+
"@swc/core": "~1.2.158",
|
|
91
91
|
"@swc/jest": "~0.2.20",
|
|
92
92
|
"@testing-library/jest-dom": "~5.16.2",
|
|
93
93
|
"@testing-library/react": "~12.1.4",
|
|
@@ -137,7 +137,7 @@
|
|
|
137
137
|
"eslint": "~8.11.0",
|
|
138
138
|
"eslint-config-airbnb": "~19.0.4",
|
|
139
139
|
"eslint-config-airbnb-base": "~15.0.0",
|
|
140
|
-
"eslint-config-airbnb-typescript": "~16.1.
|
|
140
|
+
"eslint-config-airbnb-typescript": "~16.1.3",
|
|
141
141
|
"eslint-config-prettier": "~8.5.0",
|
|
142
142
|
"eslint-config-react-app": "~7.0.0",
|
|
143
143
|
"eslint-import-resolver-babel-module": "~5.3.1",
|
|
@@ -180,7 +180,7 @@
|
|
|
180
180
|
"jscodeshift": "~0.13.1",
|
|
181
181
|
"jsdoc": "~3.6.10",
|
|
182
182
|
"lerna": "~4.0.0",
|
|
183
|
-
"lint-staged": "~12.3.
|
|
183
|
+
"lint-staged": "~12.3.7",
|
|
184
184
|
"mini-css-extract-plugin": "~2.6.0",
|
|
185
185
|
"minimist": "~1.2.5",
|
|
186
186
|
"moment": "~2.29.1",
|
|
@@ -190,10 +190,10 @@
|
|
|
190
190
|
"node-plop": "~0.30.0",
|
|
191
191
|
"nodemon": "~2.0.15",
|
|
192
192
|
"normalize-path": "~3.0.0",
|
|
193
|
-
"npm-check-updates": "12.5.
|
|
193
|
+
"npm-check-updates": "12.5.4",
|
|
194
194
|
"null-loader": "~4.0.1",
|
|
195
|
-
"pino": "~7.
|
|
196
|
-
"pino-pretty": "~7.5.
|
|
195
|
+
"pino": "~7.9.1",
|
|
196
|
+
"pino-pretty": "~7.5.4",
|
|
197
197
|
"pinst": "~3.0.0",
|
|
198
198
|
"plop": "~3.0.5",
|
|
199
199
|
"postcss": "~8.4.12",
|
|
@@ -218,7 +218,7 @@
|
|
|
218
218
|
"slackify-markdown": "~4.3.1",
|
|
219
219
|
"speed-measure-webpack-plugin": "~1.5.0",
|
|
220
220
|
"storybook-addon-turbo-build": "~1.1.0",
|
|
221
|
-
"storybook-builder-vite": "~0.1.
|
|
221
|
+
"storybook-builder-vite": "~0.1.21",
|
|
222
222
|
"storybook-react-router": "~1.0.8",
|
|
223
223
|
"style-loader": "~3.3.1",
|
|
224
224
|
"stylelint": "~14.6.0",
|
|
@@ -233,8 +233,8 @@
|
|
|
233
233
|
"url-loader": "~4.1.1",
|
|
234
234
|
"uuid": "~8.3.2",
|
|
235
235
|
"vite": "~2.8.6",
|
|
236
|
-
"vitest": "~0.
|
|
237
|
-
"webpack": "~5.
|
|
236
|
+
"vitest": "~0.7.4",
|
|
237
|
+
"webpack": "~5.70.0",
|
|
238
238
|
"webpack-bundle-analyzer": "~4.5.0",
|
|
239
239
|
"webpack-cli": "~4.9.2",
|
|
240
240
|
"webpack-dev-middleware": "~5.3.1",
|
package/lib/server/argv.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('minimist')(process.argv.slice(2));
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/* eslint-disable global-require */
|
|
2
|
-
|
|
3
|
-
module.exports = (app, options) => {
|
|
4
|
-
const isProd = process.env.NODE_ENV === 'production';
|
|
5
|
-
|
|
6
|
-
if (isProd) {
|
|
7
|
-
const addProdMiddlewares = require('./addProdMiddlewares');
|
|
8
|
-
addProdMiddlewares(app, options);
|
|
9
|
-
} else {
|
|
10
|
-
const webpackConfig = require('../../webpack/webpack.dev.babel');
|
|
11
|
-
const addDevMiddlewares = require('./addDevMiddlewares');
|
|
12
|
-
addDevMiddlewares(app, webpackConfig);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return app;
|
|
16
|
-
};
|