@commercetools-frontend/mc-scripts 22.2.1 → 22.3.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/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.dev.js +51 -41
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.prod.js +51 -41
- package/cli/dist/commercetools-frontend-mc-scripts-cli.esm.js +51 -41
- package/dist/{build-72d9896f.esm.js → build-8227e71d.esm.js} +22 -31
- package/dist/{build-4773d61a.cjs.dev.js → build-a888cacd.cjs.dev.js} +22 -31
- package/dist/{build-0ef080b9.cjs.prod.js → build-a9f085a0.cjs.prod.js} +22 -31
- package/dist/{build-vite-2dc2b366.cjs.prod.js → build-vite-1ba28dd8.cjs.prod.js} +18 -19
- package/dist/{build-vite-290aaf04.esm.js → build-vite-9de4820c.esm.js} +18 -19
- package/dist/{build-vite-b5c7ac91.cjs.dev.js → build-vite-e7a6315c.cjs.dev.js} +18 -19
- package/dist/commercetools-frontend-mc-scripts.cjs.dev.js +2 -3
- package/dist/commercetools-frontend-mc-scripts.cjs.prod.js +2 -3
- package/dist/commercetools-frontend-mc-scripts.esm.js +2 -3
- package/dist/{compile-html-41195e35.cjs.dev.js → compile-html-079067bd.cjs.prod.js} +1 -7
- package/dist/{compile-html-5abd78aa.cjs.prod.js → compile-html-3ff2fed0.cjs.dev.js} +1 -7
- package/dist/{compile-html-f9de842c.esm.js → compile-html-606b302e.esm.js} +1 -7
- package/dist/{config-sync-8e8e18a9.cjs.prod.js → config-sync-058dca05.cjs.prod.js} +81 -193
- package/dist/{config-sync-c914ca7a.cjs.dev.js → config-sync-866d8c22.cjs.dev.js} +83 -194
- package/dist/{config-sync-54299066.esm.js → config-sync-dc5a68ed.esm.js} +83 -194
- package/dist/{create-postcss-config-f39f54b5.esm.js → create-postcss-config-9d266de4.esm.js} +9 -13
- package/dist/{create-postcss-config-a0659cf5.cjs.dev.js → create-postcss-config-a29e83fc.cjs.dev.js} +9 -13
- package/dist/{create-postcss-config-6277233e.cjs.prod.js → create-postcss-config-d4f8ca51.cjs.prod.js} +9 -13
- package/dist/{create-webpack-config-for-development-629a8982.cjs.prod.js → create-webpack-config-for-development-02fa9041.cjs.prod.js} +46 -37
- package/dist/{create-webpack-config-for-development-9539f804.esm.js → create-webpack-config-for-development-17376d1f.esm.js} +46 -37
- package/dist/{create-webpack-config-for-development-9aa85081.cjs.dev.js → create-webpack-config-for-development-ac4ad0b2.cjs.dev.js} +46 -37
- package/dist/{create-webpack-config-for-production-84e2db7d.cjs.prod.js → create-webpack-config-for-production-190c7797.cjs.prod.js} +37 -32
- package/dist/{create-webpack-config-for-production-4476fc5f.esm.js → create-webpack-config-for-production-25d7c593.esm.js} +37 -32
- package/dist/{create-webpack-config-for-production-0fac47e1.cjs.dev.js → create-webpack-config-for-production-c1ec1058.cjs.dev.js} +37 -32
- package/dist/{credentials-storage-5939dd35.esm.js → credentials-storage-5a3b88be.esm.js} +3 -15
- package/dist/{credentials-storage-da0754c9.cjs.dev.js → credentials-storage-5d3da1c0.cjs.prod.js} +3 -15
- package/dist/{credentials-storage-fc0c59c3.cjs.prod.js → credentials-storage-6c51d561.cjs.dev.js} +3 -15
- package/dist/declarations/src/generated/settings.d.ts +90 -1172
- package/dist/{has-jsx-runtime-0b03b72e.cjs.prod.js → has-jsx-runtime-aa5d21ee.cjs.dev.js} +0 -2
- package/dist/{has-jsx-runtime-3d4bb633.cjs.dev.js → has-jsx-runtime-c3202df5.cjs.prod.js} +0 -2
- package/dist/{has-jsx-runtime-8314226e.esm.js → has-jsx-runtime-e3ecb09b.esm.js} +0 -2
- package/dist/{login-9f821336.cjs.dev.js → login-0dc4f62a.cjs.prod.js} +12 -23
- package/dist/{login-d1c2268a.esm.js → login-1b051481.esm.js} +12 -23
- package/dist/{login-f747390f.cjs.prod.js → login-9f35d543.cjs.dev.js} +12 -23
- package/dist/{package-83202e32.cjs.prod.js → package-46d27f5f.cjs.dev.js} +15 -13
- package/dist/{package-e6713e98.esm.js → package-4fcd2667.esm.js} +15 -13
- package/dist/{package-cc5b8665.cjs.dev.js → package-6ee0354d.cjs.prod.js} +15 -13
- package/dist/{paths-284c77fb.cjs.prod.js → paths-854af5ef.cjs.prod.js} +8 -12
- package/dist/{paths-db35ac0f.cjs.dev.js → paths-d1febc82.cjs.dev.js} +8 -12
- package/dist/{paths-55c5d5a2.esm.js → paths-ded20ae1.esm.js} +8 -12
- package/dist/{serve-b8063204.cjs.dev.js → serve-12571b42.cjs.prod.js} +1 -2
- package/dist/{serve-660e2ee0.esm.js → serve-65b5a149.esm.js} +1 -2
- package/dist/{serve-41077dad.cjs.prod.js → serve-7339c495.cjs.dev.js} +1 -2
- package/dist/{start-33fd6d70.cjs.dev.js → start-216f84b7.cjs.dev.js} +26 -34
- package/dist/{start-93205b87.esm.js → start-4a922c4f.esm.js} +26 -34
- package/dist/{start-f93c62f9.cjs.prod.js → start-b2e2dab7.cjs.prod.js} +26 -34
- package/dist/{start-vite-8f03b0df.cjs.dev.js → start-vite-3966d625.cjs.dev.js} +18 -17
- package/dist/{start-vite-324af14d.cjs.prod.js → start-vite-5c78605b.cjs.prod.js} +18 -17
- package/dist/{start-vite-7d10ae71.esm.js → start-vite-cf0213a1.esm.js} +18 -17
- package/dist/{vite-plugin-svgr-f17db78a.esm.js → vite-plugin-svgr-5c953fe7.esm.js} +1 -6
- package/dist/{vite-plugin-svgr-fdb37ccf.cjs.dev.js → vite-plugin-svgr-5eb1c511.cjs.dev.js} +1 -6
- package/dist/{vite-plugin-svgr-9a4e7f77.cjs.prod.js → vite-plugin-svgr-a732f8df.cjs.prod.js} +1 -6
- package/package.json +31 -17
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.dev.js +2 -2
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.prod.js +2 -2
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.esm.js +2 -2
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.dev.js +6 -6
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.prod.js +6 -6
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.esm.js +6 -6
|
@@ -8,8 +8,8 @@ import formatWebpackMessages from 'react-dev-utils/formatWebpackMessages';
|
|
|
8
8
|
import printBuildError from 'react-dev-utils/printBuildError';
|
|
9
9
|
import webpack from 'webpack';
|
|
10
10
|
import { packageLocation } from '@commercetools-frontend/assets';
|
|
11
|
-
import { c as createWebpackConfigForProduction } from './create-webpack-config-for-production-
|
|
12
|
-
import { p as paths } from './paths-
|
|
11
|
+
import { c as createWebpackConfigForProduction } from './create-webpack-config-for-production-25d7c593.esm.js';
|
|
12
|
+
import { p as paths } from './paths-ded20ae1.esm.js';
|
|
13
13
|
import '@babel/runtime-corejs3/core-js-stable/object/keys';
|
|
14
14
|
import '@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols';
|
|
15
15
|
import '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor';
|
|
@@ -36,39 +36,39 @@ import '@babel/runtime-corejs3/core-js-stable/instance/bind';
|
|
|
36
36
|
import '@babel/runtime-corejs3/core-js-stable/instance/reduce';
|
|
37
37
|
import '@babel/runtime-corejs3/core-js-stable/object/assign';
|
|
38
38
|
import 'fs';
|
|
39
|
-
import './create-postcss-config-
|
|
39
|
+
import './create-postcss-config-9d266de4.esm.js';
|
|
40
40
|
import '@babel/runtime-corejs3/helpers/slicedToArray';
|
|
41
|
-
import './package-
|
|
42
|
-
import './has-jsx-runtime-
|
|
41
|
+
import './package-4fcd2667.esm.js';
|
|
42
|
+
import './has-jsx-runtime-e3ecb09b.esm.js';
|
|
43
43
|
import './vendors-to-transpile-7dc84a72.esm.js';
|
|
44
44
|
import '@babel/runtime-corejs3/core-js-stable/instance/find';
|
|
45
45
|
|
|
46
46
|
const measureFileSizesBeforeBuild = FileSizeReporter.measureFileSizesBeforeBuild;
|
|
47
|
-
const printFileSizesAfterBuild = FileSizeReporter.printFileSizesAfterBuild;
|
|
47
|
+
const printFileSizesAfterBuild = FileSizeReporter.printFileSizesAfterBuild;
|
|
48
48
|
|
|
49
|
+
// These sizes are pretty large. We'll warn for bundles exceeding them.
|
|
49
50
|
const WARN_AFTER_BUNDLE_GZIP_SIZE = 512 * 1024;
|
|
50
51
|
const WARN_AFTER_CHUNK_GZIP_SIZE = 1024 * 1024;
|
|
51
|
-
|
|
52
52
|
async function run() {
|
|
53
|
-
const hasWebpackConfig = fs.existsSync(paths.appWebpackConfig);
|
|
53
|
+
const hasWebpackConfig = fs.existsSync(paths.appWebpackConfig);
|
|
54
54
|
|
|
55
|
+
// Warn and crash if required files are missing
|
|
55
56
|
if (!checkRequiredFiles([])) {
|
|
56
57
|
process.exit(1);
|
|
57
|
-
}
|
|
58
|
-
// This lets us display how much they changed later.
|
|
58
|
+
}
|
|
59
59
|
|
|
60
|
+
// First, read the current file sizes in build directory.
|
|
61
|
+
// This lets us display how much they changed later.
|
|
62
|
+
const previousFileSizes = await measureFileSizesBeforeBuild(paths.appBuild);
|
|
60
63
|
|
|
61
|
-
|
|
64
|
+
// Remove all content but keep the directory so that
|
|
62
65
|
// if you're in it, you don't end up in Trash
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
+
fs.emptyDirSync(paths.appBuild);
|
|
67
|
+
// Copy default files
|
|
66
68
|
copyDefaultFiles();
|
|
67
|
-
|
|
68
69
|
try {
|
|
69
70
|
// Start the webpack build
|
|
70
71
|
const result = await build();
|
|
71
|
-
|
|
72
72
|
if (result.warnings.length) {
|
|
73
73
|
console.log(chalk.yellow('Compiled with warnings.\n'));
|
|
74
74
|
console.log(result.warnings.join('\n\n'));
|
|
@@ -77,7 +77,6 @@ async function run() {
|
|
|
77
77
|
} else {
|
|
78
78
|
console.log(chalk.green('Compiled successfully.\n'));
|
|
79
79
|
}
|
|
80
|
-
|
|
81
80
|
console.log('File sizes after gzip:\n');
|
|
82
81
|
printFileSizesAfterBuild(result.stats, previousFileSizes, paths.appBuild, WARN_AFTER_BUNDLE_GZIP_SIZE, WARN_AFTER_CHUNK_GZIP_SIZE);
|
|
83
82
|
console.log();
|
|
@@ -85,11 +84,10 @@ async function run() {
|
|
|
85
84
|
if (error instanceof Error) {
|
|
86
85
|
printBuildError(error);
|
|
87
86
|
}
|
|
88
|
-
|
|
89
87
|
throw new Error("Failed to compile");
|
|
90
|
-
}
|
|
91
|
-
|
|
88
|
+
}
|
|
92
89
|
|
|
90
|
+
// Create the production build and print the deployment instructions.
|
|
93
91
|
async function build() {
|
|
94
92
|
console.log('Creating an optimized production build...');
|
|
95
93
|
const config = hasWebpackConfig ? require(paths.appWebpackConfig) : createWebpackConfigForProduction();
|
|
@@ -97,19 +95,17 @@ async function run() {
|
|
|
97
95
|
return new _Promise((resolve, reject) => {
|
|
98
96
|
compiler.run((err, stats) => {
|
|
99
97
|
let messages;
|
|
100
|
-
|
|
101
98
|
if (err) {
|
|
102
99
|
if (!err.message) {
|
|
103
100
|
return reject(err);
|
|
104
101
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
102
|
+
let errMessage = err.message;
|
|
103
|
+
// Add additional information for postcss errors
|
|
108
104
|
if (Object.prototype.hasOwnProperty.call(err, 'postcssNode')) {
|
|
109
|
-
errMessage += '\nCompileError: Begins at CSS selector ' +
|
|
105
|
+
errMessage += '\nCompileError: Begins at CSS selector ' +
|
|
106
|
+
// @ts-ignore
|
|
110
107
|
err['postcssNode'].selector;
|
|
111
108
|
}
|
|
112
|
-
|
|
113
109
|
messages = formatWebpackMessages({
|
|
114
110
|
// @ts-ignore
|
|
115
111
|
errors: [errMessage],
|
|
@@ -122,22 +118,18 @@ async function run() {
|
|
|
122
118
|
errors: true
|
|
123
119
|
}));
|
|
124
120
|
}
|
|
125
|
-
|
|
126
121
|
if (messages.errors.length) {
|
|
127
122
|
// Only keep the first error. Others are often indicative
|
|
128
123
|
// of the same problem, but confuse the reader with noise.
|
|
129
124
|
if (messages.errors.length > 1) {
|
|
130
125
|
messages.errors.length = 1;
|
|
131
126
|
}
|
|
132
|
-
|
|
133
127
|
return reject(new Error(messages.errors.join('\n\n')));
|
|
134
128
|
}
|
|
135
|
-
|
|
136
129
|
if (process.env.CI && (typeof process.env.CI !== 'string' || process.env.CI.toLowerCase() !== 'false') && messages.warnings.length) {
|
|
137
130
|
console.log(chalk.yellow('\nTreating warnings as errors because process.env.CI = true.\n' + 'Most CI servers set it automatically.\n'));
|
|
138
131
|
return reject(new Error(messages.warnings.join('\n\n')));
|
|
139
132
|
}
|
|
140
|
-
|
|
141
133
|
return resolve({
|
|
142
134
|
stats: stats,
|
|
143
135
|
warnings: messages.warnings
|
|
@@ -145,7 +137,6 @@ async function run() {
|
|
|
145
137
|
});
|
|
146
138
|
});
|
|
147
139
|
}
|
|
148
|
-
|
|
149
140
|
function copyDefaultFiles() {
|
|
150
141
|
fs.copySync(path.join(packageLocation, 'html-page'), paths.appBuild, {
|
|
151
142
|
dereference: true
|
|
@@ -10,8 +10,8 @@ var formatWebpackMessages = require('react-dev-utils/formatWebpackMessages');
|
|
|
10
10
|
var printBuildError = require('react-dev-utils/printBuildError');
|
|
11
11
|
var webpack = require('webpack');
|
|
12
12
|
var assets = require('@commercetools-frontend/assets');
|
|
13
|
-
var createWebpackConfigForProduction = require('./create-webpack-config-for-production-
|
|
14
|
-
var paths = require('./paths-
|
|
13
|
+
var createWebpackConfigForProduction = require('./create-webpack-config-for-production-c1ec1058.cjs.dev.js');
|
|
14
|
+
var paths = require('./paths-d1febc82.cjs.dev.js');
|
|
15
15
|
require('@babel/runtime-corejs3/core-js-stable/object/keys');
|
|
16
16
|
require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
|
|
17
17
|
require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
|
|
@@ -38,10 +38,10 @@ require('@babel/runtime-corejs3/core-js-stable/instance/bind');
|
|
|
38
38
|
require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
|
|
39
39
|
require('@babel/runtime-corejs3/core-js-stable/object/assign');
|
|
40
40
|
require('fs');
|
|
41
|
-
require('./create-postcss-config-
|
|
41
|
+
require('./create-postcss-config-a29e83fc.cjs.dev.js');
|
|
42
42
|
require('@babel/runtime-corejs3/helpers/slicedToArray');
|
|
43
|
-
require('./package-
|
|
44
|
-
require('./has-jsx-runtime-
|
|
43
|
+
require('./package-46d27f5f.cjs.dev.js');
|
|
44
|
+
require('./has-jsx-runtime-aa5d21ee.cjs.dev.js');
|
|
45
45
|
require('./vendors-to-transpile-6ab4ea06.cjs.dev.js');
|
|
46
46
|
require('@babel/runtime-corejs3/core-js-stable/instance/find');
|
|
47
47
|
|
|
@@ -58,31 +58,31 @@ var printBuildError__default = /*#__PURE__*/_interopDefault(printBuildError);
|
|
|
58
58
|
var webpack__default = /*#__PURE__*/_interopDefault(webpack);
|
|
59
59
|
|
|
60
60
|
const measureFileSizesBeforeBuild = FileSizeReporter__default["default"].measureFileSizesBeforeBuild;
|
|
61
|
-
const printFileSizesAfterBuild = FileSizeReporter__default["default"].printFileSizesAfterBuild;
|
|
61
|
+
const printFileSizesAfterBuild = FileSizeReporter__default["default"].printFileSizesAfterBuild;
|
|
62
62
|
|
|
63
|
+
// These sizes are pretty large. We'll warn for bundles exceeding them.
|
|
63
64
|
const WARN_AFTER_BUNDLE_GZIP_SIZE = 512 * 1024;
|
|
64
65
|
const WARN_AFTER_CHUNK_GZIP_SIZE = 1024 * 1024;
|
|
65
|
-
|
|
66
66
|
async function run() {
|
|
67
|
-
const hasWebpackConfig = fs__default["default"].existsSync(paths.paths.appWebpackConfig);
|
|
67
|
+
const hasWebpackConfig = fs__default["default"].existsSync(paths.paths.appWebpackConfig);
|
|
68
68
|
|
|
69
|
+
// Warn and crash if required files are missing
|
|
69
70
|
if (!checkRequiredFiles__default["default"]([])) {
|
|
70
71
|
process.exit(1);
|
|
71
|
-
}
|
|
72
|
-
// This lets us display how much they changed later.
|
|
72
|
+
}
|
|
73
73
|
|
|
74
|
+
// First, read the current file sizes in build directory.
|
|
75
|
+
// This lets us display how much they changed later.
|
|
76
|
+
const previousFileSizes = await measureFileSizesBeforeBuild(paths.paths.appBuild);
|
|
74
77
|
|
|
75
|
-
|
|
78
|
+
// Remove all content but keep the directory so that
|
|
76
79
|
// if you're in it, you don't end up in Trash
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
+
fs__default["default"].emptyDirSync(paths.paths.appBuild);
|
|
81
|
+
// Copy default files
|
|
80
82
|
copyDefaultFiles();
|
|
81
|
-
|
|
82
83
|
try {
|
|
83
84
|
// Start the webpack build
|
|
84
85
|
const result = await build();
|
|
85
|
-
|
|
86
86
|
if (result.warnings.length) {
|
|
87
87
|
console.log(chalk__default["default"].yellow('Compiled with warnings.\n'));
|
|
88
88
|
console.log(result.warnings.join('\n\n'));
|
|
@@ -91,7 +91,6 @@ async function run() {
|
|
|
91
91
|
} else {
|
|
92
92
|
console.log(chalk__default["default"].green('Compiled successfully.\n'));
|
|
93
93
|
}
|
|
94
|
-
|
|
95
94
|
console.log('File sizes after gzip:\n');
|
|
96
95
|
printFileSizesAfterBuild(result.stats, previousFileSizes, paths.paths.appBuild, WARN_AFTER_BUNDLE_GZIP_SIZE, WARN_AFTER_CHUNK_GZIP_SIZE);
|
|
97
96
|
console.log();
|
|
@@ -99,11 +98,10 @@ async function run() {
|
|
|
99
98
|
if (error instanceof Error) {
|
|
100
99
|
printBuildError__default["default"](error);
|
|
101
100
|
}
|
|
102
|
-
|
|
103
101
|
throw new Error("Failed to compile");
|
|
104
|
-
}
|
|
105
|
-
|
|
102
|
+
}
|
|
106
103
|
|
|
104
|
+
// Create the production build and print the deployment instructions.
|
|
107
105
|
async function build() {
|
|
108
106
|
console.log('Creating an optimized production build...');
|
|
109
107
|
const config = hasWebpackConfig ? require(paths.paths.appWebpackConfig) : createWebpackConfigForProduction.createWebpackConfigForProduction();
|
|
@@ -111,19 +109,17 @@ async function run() {
|
|
|
111
109
|
return new _Promise__default["default"]((resolve, reject) => {
|
|
112
110
|
compiler.run((err, stats) => {
|
|
113
111
|
let messages;
|
|
114
|
-
|
|
115
112
|
if (err) {
|
|
116
113
|
if (!err.message) {
|
|
117
114
|
return reject(err);
|
|
118
115
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
116
|
+
let errMessage = err.message;
|
|
117
|
+
// Add additional information for postcss errors
|
|
122
118
|
if (Object.prototype.hasOwnProperty.call(err, 'postcssNode')) {
|
|
123
|
-
errMessage += '\nCompileError: Begins at CSS selector ' +
|
|
119
|
+
errMessage += '\nCompileError: Begins at CSS selector ' +
|
|
120
|
+
// @ts-ignore
|
|
124
121
|
err['postcssNode'].selector;
|
|
125
122
|
}
|
|
126
|
-
|
|
127
123
|
messages = formatWebpackMessages__default["default"]({
|
|
128
124
|
// @ts-ignore
|
|
129
125
|
errors: [errMessage],
|
|
@@ -136,22 +132,18 @@ async function run() {
|
|
|
136
132
|
errors: true
|
|
137
133
|
}));
|
|
138
134
|
}
|
|
139
|
-
|
|
140
135
|
if (messages.errors.length) {
|
|
141
136
|
// Only keep the first error. Others are often indicative
|
|
142
137
|
// of the same problem, but confuse the reader with noise.
|
|
143
138
|
if (messages.errors.length > 1) {
|
|
144
139
|
messages.errors.length = 1;
|
|
145
140
|
}
|
|
146
|
-
|
|
147
141
|
return reject(new Error(messages.errors.join('\n\n')));
|
|
148
142
|
}
|
|
149
|
-
|
|
150
143
|
if (process.env.CI && (typeof process.env.CI !== 'string' || process.env.CI.toLowerCase() !== 'false') && messages.warnings.length) {
|
|
151
144
|
console.log(chalk__default["default"].yellow('\nTreating warnings as errors because process.env.CI = true.\n' + 'Most CI servers set it automatically.\n'));
|
|
152
145
|
return reject(new Error(messages.warnings.join('\n\n')));
|
|
153
146
|
}
|
|
154
|
-
|
|
155
147
|
return resolve({
|
|
156
148
|
stats: stats,
|
|
157
149
|
warnings: messages.warnings
|
|
@@ -159,7 +151,6 @@ async function run() {
|
|
|
159
151
|
});
|
|
160
152
|
});
|
|
161
153
|
}
|
|
162
|
-
|
|
163
154
|
function copyDefaultFiles() {
|
|
164
155
|
fs__default["default"].copySync(path__default["default"].join(assets.packageLocation, 'html-page'), paths.paths.appBuild, {
|
|
165
156
|
dereference: true
|
|
@@ -10,8 +10,8 @@ var formatWebpackMessages = require('react-dev-utils/formatWebpackMessages');
|
|
|
10
10
|
var printBuildError = require('react-dev-utils/printBuildError');
|
|
11
11
|
var webpack = require('webpack');
|
|
12
12
|
var assets = require('@commercetools-frontend/assets');
|
|
13
|
-
var createWebpackConfigForProduction = require('./create-webpack-config-for-production-
|
|
14
|
-
var paths = require('./paths-
|
|
13
|
+
var createWebpackConfigForProduction = require('./create-webpack-config-for-production-190c7797.cjs.prod.js');
|
|
14
|
+
var paths = require('./paths-854af5ef.cjs.prod.js');
|
|
15
15
|
require('@babel/runtime-corejs3/core-js-stable/object/keys');
|
|
16
16
|
require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
|
|
17
17
|
require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
|
|
@@ -38,10 +38,10 @@ require('@babel/runtime-corejs3/core-js-stable/instance/bind');
|
|
|
38
38
|
require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
|
|
39
39
|
require('@babel/runtime-corejs3/core-js-stable/object/assign');
|
|
40
40
|
require('fs');
|
|
41
|
-
require('./create-postcss-config-
|
|
41
|
+
require('./create-postcss-config-d4f8ca51.cjs.prod.js');
|
|
42
42
|
require('@babel/runtime-corejs3/helpers/slicedToArray');
|
|
43
|
-
require('./package-
|
|
44
|
-
require('./has-jsx-runtime-
|
|
43
|
+
require('./package-6ee0354d.cjs.prod.js');
|
|
44
|
+
require('./has-jsx-runtime-c3202df5.cjs.prod.js');
|
|
45
45
|
require('./vendors-to-transpile-04a49d40.cjs.prod.js');
|
|
46
46
|
require('@babel/runtime-corejs3/core-js-stable/instance/find');
|
|
47
47
|
|
|
@@ -58,31 +58,31 @@ var printBuildError__default = /*#__PURE__*/_interopDefault(printBuildError);
|
|
|
58
58
|
var webpack__default = /*#__PURE__*/_interopDefault(webpack);
|
|
59
59
|
|
|
60
60
|
const measureFileSizesBeforeBuild = FileSizeReporter__default["default"].measureFileSizesBeforeBuild;
|
|
61
|
-
const printFileSizesAfterBuild = FileSizeReporter__default["default"].printFileSizesAfterBuild;
|
|
61
|
+
const printFileSizesAfterBuild = FileSizeReporter__default["default"].printFileSizesAfterBuild;
|
|
62
62
|
|
|
63
|
+
// These sizes are pretty large. We'll warn for bundles exceeding them.
|
|
63
64
|
const WARN_AFTER_BUNDLE_GZIP_SIZE = 512 * 1024;
|
|
64
65
|
const WARN_AFTER_CHUNK_GZIP_SIZE = 1024 * 1024;
|
|
65
|
-
|
|
66
66
|
async function run() {
|
|
67
|
-
const hasWebpackConfig = fs__default["default"].existsSync(paths.paths.appWebpackConfig);
|
|
67
|
+
const hasWebpackConfig = fs__default["default"].existsSync(paths.paths.appWebpackConfig);
|
|
68
68
|
|
|
69
|
+
// Warn and crash if required files are missing
|
|
69
70
|
if (!checkRequiredFiles__default["default"]([])) {
|
|
70
71
|
process.exit(1);
|
|
71
|
-
}
|
|
72
|
-
// This lets us display how much they changed later.
|
|
72
|
+
}
|
|
73
73
|
|
|
74
|
+
// First, read the current file sizes in build directory.
|
|
75
|
+
// This lets us display how much they changed later.
|
|
76
|
+
const previousFileSizes = await measureFileSizesBeforeBuild(paths.paths.appBuild);
|
|
74
77
|
|
|
75
|
-
|
|
78
|
+
// Remove all content but keep the directory so that
|
|
76
79
|
// if you're in it, you don't end up in Trash
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
+
fs__default["default"].emptyDirSync(paths.paths.appBuild);
|
|
81
|
+
// Copy default files
|
|
80
82
|
copyDefaultFiles();
|
|
81
|
-
|
|
82
83
|
try {
|
|
83
84
|
// Start the webpack build
|
|
84
85
|
const result = await build();
|
|
85
|
-
|
|
86
86
|
if (result.warnings.length) {
|
|
87
87
|
console.log(chalk__default["default"].yellow('Compiled with warnings.\n'));
|
|
88
88
|
console.log(result.warnings.join('\n\n'));
|
|
@@ -91,7 +91,6 @@ async function run() {
|
|
|
91
91
|
} else {
|
|
92
92
|
console.log(chalk__default["default"].green('Compiled successfully.\n'));
|
|
93
93
|
}
|
|
94
|
-
|
|
95
94
|
console.log('File sizes after gzip:\n');
|
|
96
95
|
printFileSizesAfterBuild(result.stats, previousFileSizes, paths.paths.appBuild, WARN_AFTER_BUNDLE_GZIP_SIZE, WARN_AFTER_CHUNK_GZIP_SIZE);
|
|
97
96
|
console.log();
|
|
@@ -99,11 +98,10 @@ async function run() {
|
|
|
99
98
|
if (error instanceof Error) {
|
|
100
99
|
printBuildError__default["default"](error);
|
|
101
100
|
}
|
|
102
|
-
|
|
103
101
|
throw new Error("Failed to compile");
|
|
104
|
-
}
|
|
105
|
-
|
|
102
|
+
}
|
|
106
103
|
|
|
104
|
+
// Create the production build and print the deployment instructions.
|
|
107
105
|
async function build() {
|
|
108
106
|
console.log('Creating an optimized production build...');
|
|
109
107
|
const config = hasWebpackConfig ? require(paths.paths.appWebpackConfig) : createWebpackConfigForProduction.createWebpackConfigForProduction();
|
|
@@ -111,19 +109,17 @@ async function run() {
|
|
|
111
109
|
return new _Promise__default["default"]((resolve, reject) => {
|
|
112
110
|
compiler.run((err, stats) => {
|
|
113
111
|
let messages;
|
|
114
|
-
|
|
115
112
|
if (err) {
|
|
116
113
|
if (!err.message) {
|
|
117
114
|
return reject(err);
|
|
118
115
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
116
|
+
let errMessage = err.message;
|
|
117
|
+
// Add additional information for postcss errors
|
|
122
118
|
if (Object.prototype.hasOwnProperty.call(err, 'postcssNode')) {
|
|
123
|
-
errMessage += '\nCompileError: Begins at CSS selector ' +
|
|
119
|
+
errMessage += '\nCompileError: Begins at CSS selector ' +
|
|
120
|
+
// @ts-ignore
|
|
124
121
|
err['postcssNode'].selector;
|
|
125
122
|
}
|
|
126
|
-
|
|
127
123
|
messages = formatWebpackMessages__default["default"]({
|
|
128
124
|
// @ts-ignore
|
|
129
125
|
errors: [errMessage],
|
|
@@ -136,22 +132,18 @@ async function run() {
|
|
|
136
132
|
errors: true
|
|
137
133
|
}));
|
|
138
134
|
}
|
|
139
|
-
|
|
140
135
|
if (messages.errors.length) {
|
|
141
136
|
// Only keep the first error. Others are often indicative
|
|
142
137
|
// of the same problem, but confuse the reader with noise.
|
|
143
138
|
if (messages.errors.length > 1) {
|
|
144
139
|
messages.errors.length = 1;
|
|
145
140
|
}
|
|
146
|
-
|
|
147
141
|
return reject(new Error(messages.errors.join('\n\n')));
|
|
148
142
|
}
|
|
149
|
-
|
|
150
143
|
if (process.env.CI && (typeof process.env.CI !== 'string' || process.env.CI.toLowerCase() !== 'false') && messages.warnings.length) {
|
|
151
144
|
console.log(chalk__default["default"].yellow('\nTreating warnings as errors because process.env.CI = true.\n' + 'Most CI servers set it automatically.\n'));
|
|
152
145
|
return reject(new Error(messages.warnings.join('\n\n')));
|
|
153
146
|
}
|
|
154
|
-
|
|
155
147
|
return resolve({
|
|
156
148
|
stats: stats,
|
|
157
149
|
warnings: messages.warnings
|
|
@@ -159,7 +151,6 @@ async function run() {
|
|
|
159
151
|
});
|
|
160
152
|
});
|
|
161
153
|
}
|
|
162
|
-
|
|
163
154
|
function copyDefaultFiles() {
|
|
164
155
|
fs__default["default"].copySync(path__default["default"].join(assets.packageLocation, 'html-page'), paths.paths.appBuild, {
|
|
165
156
|
dereference: true
|
|
@@ -9,8 +9,8 @@ var fs = require('fs-extra');
|
|
|
9
9
|
var vite = require('vite');
|
|
10
10
|
var assets = require('@commercetools-frontend/assets');
|
|
11
11
|
var mcHtmlTemplate = require('@commercetools-frontend/mc-html-template');
|
|
12
|
-
var paths = require('./paths-
|
|
13
|
-
var vitePluginSvgr = require('./vite-plugin-svgr-
|
|
12
|
+
var paths = require('./paths-854af5ef.cjs.prod.js');
|
|
13
|
+
var vitePluginSvgr = require('./vite-plugin-svgr-a732f8df.cjs.prod.js');
|
|
14
14
|
require('@babel/runtime-corejs3/core-js-stable/instance/find');
|
|
15
15
|
require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
16
16
|
require('fs');
|
|
@@ -29,11 +29,9 @@ var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
|
29
29
|
// on runtime to build the assets URL (for example when using a separate CDN for the assets).
|
|
30
30
|
// Inspired by https://github.com/vitejs/vite/blob/main/playground/assets/vite.config-runtime-base.js
|
|
31
31
|
const dynamicBaseAssetsCode = "globalThis.__toCdnUrl = filePath => window.app.cdnUrl.replace(/\\/$/, '') + '/' + filePath;";
|
|
32
|
-
|
|
33
32
|
function vitePluginDynamicBaseAssetsGlobals() {
|
|
34
33
|
return {
|
|
35
34
|
name: 'dynamic-base-assets-globals',
|
|
36
|
-
|
|
37
35
|
transformIndexHtml(html, ctx) {
|
|
38
36
|
if (ctx.bundle) {
|
|
39
37
|
// Only inject during build
|
|
@@ -45,27 +43,27 @@ function vitePluginDynamicBaseAssetsGlobals() {
|
|
|
45
43
|
children: dynamicBaseAssetsCode
|
|
46
44
|
}];
|
|
47
45
|
}
|
|
48
|
-
|
|
49
46
|
return html;
|
|
50
47
|
}
|
|
51
|
-
|
|
52
48
|
};
|
|
53
49
|
}
|
|
54
50
|
|
|
55
51
|
async function run() {
|
|
56
|
-
const DEFAULT_PORT = _parseInt__default["default"](String(process.env.HTTP_PORT), 10) || 3001;
|
|
52
|
+
const DEFAULT_PORT = _parseInt__default["default"](String(process.env.HTTP_PORT), 10) || 3001;
|
|
57
53
|
|
|
54
|
+
// Ensure the `/public` folder exists.
|
|
58
55
|
fs__default["default"].mkdirSync(paths.paths.appBuild, {
|
|
59
56
|
recursive: true
|
|
60
|
-
});
|
|
57
|
+
});
|
|
61
58
|
|
|
59
|
+
// Generate `index.html` (template).
|
|
62
60
|
const appEntryPoint = path__default["default"].relative(paths.paths.appRoot, paths.paths.entryPoint);
|
|
63
61
|
const html = mcHtmlTemplate.generateTemplate({
|
|
64
62
|
// Define the module entry point (path relative from the `/public` folder).
|
|
65
63
|
// NOTE: that this is different from the development configuration.
|
|
66
64
|
scriptImports: ["<script type=\"module\" src=\"/".concat(appEntryPoint, "\"></script>")]
|
|
67
|
-
});
|
|
68
|
-
|
|
65
|
+
});
|
|
66
|
+
// Write `index.html` (template) into the `/public` folder.
|
|
69
67
|
fs__default["default"].writeFileSync(paths.paths.appIndexHtml, html, {
|
|
70
68
|
encoding: 'utf8'
|
|
71
69
|
});
|
|
@@ -89,7 +87,8 @@ async function run() {
|
|
|
89
87
|
// https://github.com/vitejs/vite/issues/2433#issuecomment-1361094727
|
|
90
88
|
cache: false
|
|
91
89
|
},
|
|
92
|
-
sourcemap:
|
|
90
|
+
sourcemap:
|
|
91
|
+
// Generating sourcemaps can increase the memory footprint of the build process,
|
|
93
92
|
// therefore it's an opt-in option.
|
|
94
93
|
// TODO: make it a CLI option when Vite support becomes stable.
|
|
95
94
|
process.env.ENABLE_EXPERIMENTAL_VITE_BUNDLER_SOURCEMAP === 'true'
|
|
@@ -101,16 +100,13 @@ async function run() {
|
|
|
101
100
|
// https://vitejs.dev/guide/build.html#advanced-base-options
|
|
102
101
|
renderBuiltUrl(filename, _ref) {
|
|
103
102
|
let hostType = _ref.hostType;
|
|
104
|
-
|
|
105
103
|
if (hostType === 'html') {
|
|
106
104
|
return "__CDN_URL__".concat(filename);
|
|
107
105
|
}
|
|
108
|
-
|
|
109
106
|
return {
|
|
110
107
|
runtime: "window.__toCdnUrl(".concat(_JSON$stringify__default["default"](filename), ")")
|
|
111
108
|
};
|
|
112
109
|
}
|
|
113
|
-
|
|
114
110
|
},
|
|
115
111
|
plugins: [pluginGraphql__default["default"](), pluginReact__default["default"]({
|
|
116
112
|
jsxImportSource: '@emotion/react',
|
|
@@ -118,16 +114,19 @@ async function run() {
|
|
|
118
114
|
plugins: ['@emotion/babel-plugin', '@babel/plugin-proposal-do-expressions']
|
|
119
115
|
}
|
|
120
116
|
}), vitePluginSvgr.vitePluginSvgr(), vitePluginDynamicBaseAssetsGlobals()]
|
|
121
|
-
});
|
|
117
|
+
});
|
|
122
118
|
|
|
123
|
-
|
|
119
|
+
// Rename `/public/public/index.html` to `/public/index.html.template`
|
|
120
|
+
fs__default["default"].renameSync(
|
|
121
|
+
// Because of our custom entry point path (`/public/index.html`),
|
|
124
122
|
// Vite will write the `index.html` to `/public/public/index.html`.
|
|
125
123
|
// We need to move this file to the `/public` folder and rename it
|
|
126
124
|
// to `index.html.template` (as expected by the `compile-html` command).
|
|
127
|
-
path__default["default"].join(paths.paths.appBuild, 'public/index.html'), paths.paths.appIndexHtmlTemplate);
|
|
128
|
-
|
|
129
|
-
fs__default["default"].rmdirSync(path__default["default"].join(paths.paths.appBuild, 'public'));
|
|
125
|
+
path__default["default"].join(paths.paths.appBuild, 'public/index.html'), paths.paths.appIndexHtmlTemplate);
|
|
126
|
+
// Clean up nested folder
|
|
127
|
+
fs__default["default"].rmdirSync(path__default["default"].join(paths.paths.appBuild, 'public'));
|
|
130
128
|
|
|
129
|
+
// Copy public assets
|
|
131
130
|
fs__default["default"].copySync(path__default["default"].join(assets.packageLocation, 'html-page'), paths.paths.appBuild, {
|
|
132
131
|
dereference: true
|
|
133
132
|
});
|
|
@@ -7,8 +7,8 @@ import fs from 'fs-extra';
|
|
|
7
7
|
import { build } from 'vite';
|
|
8
8
|
import { packageLocation } from '@commercetools-frontend/assets';
|
|
9
9
|
import { generateTemplate } from '@commercetools-frontend/mc-html-template';
|
|
10
|
-
import { p as paths } from './paths-
|
|
11
|
-
import { v as vitePluginSvgr } from './vite-plugin-svgr-
|
|
10
|
+
import { p as paths } from './paths-ded20ae1.esm.js';
|
|
11
|
+
import { v as vitePluginSvgr } from './vite-plugin-svgr-5c953fe7.esm.js';
|
|
12
12
|
import '@babel/runtime-corejs3/core-js-stable/instance/find';
|
|
13
13
|
import '@babel/runtime-corejs3/core-js-stable/instance/concat';
|
|
14
14
|
import 'fs';
|
|
@@ -18,11 +18,9 @@ import '@rollup/pluginutils';
|
|
|
18
18
|
// on runtime to build the assets URL (for example when using a separate CDN for the assets).
|
|
19
19
|
// Inspired by https://github.com/vitejs/vite/blob/main/playground/assets/vite.config-runtime-base.js
|
|
20
20
|
const dynamicBaseAssetsCode = "globalThis.__toCdnUrl = filePath => window.app.cdnUrl.replace(/\\/$/, '') + '/' + filePath;";
|
|
21
|
-
|
|
22
21
|
function vitePluginDynamicBaseAssetsGlobals() {
|
|
23
22
|
return {
|
|
24
23
|
name: 'dynamic-base-assets-globals',
|
|
25
|
-
|
|
26
24
|
transformIndexHtml(html, ctx) {
|
|
27
25
|
if (ctx.bundle) {
|
|
28
26
|
// Only inject during build
|
|
@@ -34,27 +32,27 @@ function vitePluginDynamicBaseAssetsGlobals() {
|
|
|
34
32
|
children: dynamicBaseAssetsCode
|
|
35
33
|
}];
|
|
36
34
|
}
|
|
37
|
-
|
|
38
35
|
return html;
|
|
39
36
|
}
|
|
40
|
-
|
|
41
37
|
};
|
|
42
38
|
}
|
|
43
39
|
|
|
44
40
|
async function run() {
|
|
45
|
-
const DEFAULT_PORT = _parseInt(String(process.env.HTTP_PORT), 10) || 3001;
|
|
41
|
+
const DEFAULT_PORT = _parseInt(String(process.env.HTTP_PORT), 10) || 3001;
|
|
46
42
|
|
|
43
|
+
// Ensure the `/public` folder exists.
|
|
47
44
|
fs.mkdirSync(paths.appBuild, {
|
|
48
45
|
recursive: true
|
|
49
|
-
});
|
|
46
|
+
});
|
|
50
47
|
|
|
48
|
+
// Generate `index.html` (template).
|
|
51
49
|
const appEntryPoint = path.relative(paths.appRoot, paths.entryPoint);
|
|
52
50
|
const html = generateTemplate({
|
|
53
51
|
// Define the module entry point (path relative from the `/public` folder).
|
|
54
52
|
// NOTE: that this is different from the development configuration.
|
|
55
53
|
scriptImports: ["<script type=\"module\" src=\"/".concat(appEntryPoint, "\"></script>")]
|
|
56
|
-
});
|
|
57
|
-
|
|
54
|
+
});
|
|
55
|
+
// Write `index.html` (template) into the `/public` folder.
|
|
58
56
|
fs.writeFileSync(paths.appIndexHtml, html, {
|
|
59
57
|
encoding: 'utf8'
|
|
60
58
|
});
|
|
@@ -78,7 +76,8 @@ async function run() {
|
|
|
78
76
|
// https://github.com/vitejs/vite/issues/2433#issuecomment-1361094727
|
|
79
77
|
cache: false
|
|
80
78
|
},
|
|
81
|
-
sourcemap:
|
|
79
|
+
sourcemap:
|
|
80
|
+
// Generating sourcemaps can increase the memory footprint of the build process,
|
|
82
81
|
// therefore it's an opt-in option.
|
|
83
82
|
// TODO: make it a CLI option when Vite support becomes stable.
|
|
84
83
|
process.env.ENABLE_EXPERIMENTAL_VITE_BUNDLER_SOURCEMAP === 'true'
|
|
@@ -90,16 +89,13 @@ async function run() {
|
|
|
90
89
|
// https://vitejs.dev/guide/build.html#advanced-base-options
|
|
91
90
|
renderBuiltUrl(filename, _ref) {
|
|
92
91
|
let hostType = _ref.hostType;
|
|
93
|
-
|
|
94
92
|
if (hostType === 'html') {
|
|
95
93
|
return "__CDN_URL__".concat(filename);
|
|
96
94
|
}
|
|
97
|
-
|
|
98
95
|
return {
|
|
99
96
|
runtime: "window.__toCdnUrl(".concat(_JSON$stringify(filename), ")")
|
|
100
97
|
};
|
|
101
98
|
}
|
|
102
|
-
|
|
103
99
|
},
|
|
104
100
|
plugins: [pluginGraphql(), pluginReact({
|
|
105
101
|
jsxImportSource: '@emotion/react',
|
|
@@ -107,16 +103,19 @@ async function run() {
|
|
|
107
103
|
plugins: ['@emotion/babel-plugin', '@babel/plugin-proposal-do-expressions']
|
|
108
104
|
}
|
|
109
105
|
}), vitePluginSvgr(), vitePluginDynamicBaseAssetsGlobals()]
|
|
110
|
-
});
|
|
106
|
+
});
|
|
111
107
|
|
|
112
|
-
|
|
108
|
+
// Rename `/public/public/index.html` to `/public/index.html.template`
|
|
109
|
+
fs.renameSync(
|
|
110
|
+
// Because of our custom entry point path (`/public/index.html`),
|
|
113
111
|
// Vite will write the `index.html` to `/public/public/index.html`.
|
|
114
112
|
// We need to move this file to the `/public` folder and rename it
|
|
115
113
|
// to `index.html.template` (as expected by the `compile-html` command).
|
|
116
|
-
path.join(paths.appBuild, 'public/index.html'), paths.appIndexHtmlTemplate);
|
|
117
|
-
|
|
118
|
-
fs.rmdirSync(path.join(paths.appBuild, 'public'));
|
|
114
|
+
path.join(paths.appBuild, 'public/index.html'), paths.appIndexHtmlTemplate);
|
|
115
|
+
// Clean up nested folder
|
|
116
|
+
fs.rmdirSync(path.join(paths.appBuild, 'public'));
|
|
119
117
|
|
|
118
|
+
// Copy public assets
|
|
120
119
|
fs.copySync(path.join(packageLocation, 'html-page'), paths.appBuild, {
|
|
121
120
|
dereference: true
|
|
122
121
|
});
|