@elliemae/pui-cli 6.13.0-beta.3 → 7.0.0-beta.1
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.
|
@@ -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,29 @@ 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
|
+
exports.copyBuildAssetsToVersionedFolder = async () => {
|
|
121
|
+
const appVersion = getAppVersion();
|
|
122
|
+
const isVersionedApp = isAppLoaderEnabled() && appVersion !== LATEST_VERSION;
|
|
123
|
+
if (!isVersionedApp) return;
|
|
124
|
+
const src = path.resolve(process.cwd(), 'build/public/latest');
|
|
125
|
+
const dest = path.resolve(process.cwd(), `build/public/${appVersion}`);
|
|
126
|
+
copyDir(src, dest);
|
|
127
|
+
};
|
package/lib/webpack/helpers.js
CHANGED
|
@@ -226,6 +226,7 @@ const filterByFilePresence = (patterns) =>
|
|
|
226
226
|
!noErrorOnMissing || fs.existsSync(path.resolve(process.cwd(), from)),
|
|
227
227
|
);
|
|
228
228
|
|
|
229
|
+
exports.LATEST_VERSION = LATEST_VERSION;
|
|
229
230
|
exports.excludeNodeModulesExcept = excludeNodeModulesExcept;
|
|
230
231
|
exports.getLibraryName = getLibraryName;
|
|
231
232
|
exports.getAppConfig = getAppConfig;
|
|
@@ -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');
|
|
@@ -122,21 +120,13 @@ const htmlWebpackPlugin = new HtmlWebpackPlugin({
|
|
|
122
120
|
},
|
|
123
121
|
});
|
|
124
122
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
isAppLoaderEnabled() && getAppVersion() !== LATEST_VERSION;
|
|
123
|
+
const config = baseConfigFactory(getProdConfig());
|
|
124
|
+
config.plugins.push(htmlWebpackPlugin);
|
|
128
125
|
|
|
129
|
-
const
|
|
130
|
-
latestVersionConfig.plugins.push(htmlWebpackPlugin);
|
|
131
|
-
|
|
132
|
-
const appVersionConfig = baseConfigFactory(
|
|
133
|
-
getProdConfig({ latestVersion: false }),
|
|
134
|
-
);
|
|
135
|
-
|
|
136
|
-
const addSMPPlugin = (config) => {
|
|
126
|
+
const addSMPPlugin = (webpackConfig) => {
|
|
137
127
|
const smpConfig = new SpeedMeasurePlugin({
|
|
138
128
|
disable: !process.env.MEASURE,
|
|
139
|
-
}).wrap(
|
|
129
|
+
}).wrap(webpackConfig);
|
|
140
130
|
// mini css extract plugin is not working fine with smp
|
|
141
131
|
smpConfig.plugins.push(
|
|
142
132
|
new MiniCssExtractPlugin({
|
|
@@ -147,8 +137,4 @@ const addSMPPlugin = (config) => {
|
|
|
147
137
|
return smpConfig;
|
|
148
138
|
};
|
|
149
139
|
|
|
150
|
-
|
|
151
|
-
? [latestVersionConfig, appVersionConfig].map(addSMPPlugin)
|
|
152
|
-
: addSMPPlugin(latestVersionConfig);
|
|
153
|
-
|
|
154
|
-
module.exports = config;
|
|
140
|
+
module.exports = addSMPPlugin(config);
|