@commercetools-frontend/mc-scripts 21.23.10 → 21.24.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.
Files changed (89) hide show
  1. package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.dev.js +120 -326
  2. package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.prod.js +120 -326
  3. package/cli/dist/commercetools-frontend-mc-scripts-cli.esm.js +116 -321
  4. package/dist/build-980cf2c9.cjs.prod.js +170 -0
  5. package/dist/build-c9601b07.esm.js +156 -0
  6. package/dist/build-e8a49b56.cjs.dev.js +170 -0
  7. package/dist/build-vite-b531d3d3.esm.js +118 -0
  8. package/dist/build-vite-c40a55c3.cjs.dev.js +129 -0
  9. package/dist/build-vite-d17432ec.cjs.prod.js +129 -0
  10. package/dist/commercetools-frontend-mc-scripts.cjs.dev.js +2 -2
  11. package/dist/commercetools-frontend-mc-scripts.cjs.prod.js +2 -2
  12. package/dist/commercetools-frontend-mc-scripts.esm.js +2 -2
  13. package/dist/compile-html-41195e35.cjs.dev.js +49 -0
  14. package/dist/compile-html-5abd78aa.cjs.prod.js +49 -0
  15. package/dist/compile-html-f9de842c.esm.js +40 -0
  16. package/dist/config-sync-0ecc13b3.cjs.dev.js +783 -0
  17. package/dist/config-sync-4b1ddec3.esm.js +759 -0
  18. package/dist/config-sync-bb59a82d.cjs.prod.js +778 -0
  19. package/dist/{create-postcss-config-f65c7e31.cjs.dev.js → create-postcss-config-5cc679d5.cjs.dev.js} +9 -14
  20. package/dist/{create-postcss-config-06b2e5c2.esm.js → create-postcss-config-a0d4cffa.esm.js} +9 -13
  21. package/dist/{create-postcss-config-787d905f.cjs.prod.js → create-postcss-config-f94c07fd.cjs.prod.js} +9 -14
  22. package/dist/{create-webpack-config-for-development-fd365d6a.esm.js → create-webpack-config-for-development-95334073.esm.js} +21 -25
  23. package/dist/{create-webpack-config-for-development-d46ef148.cjs.dev.js → create-webpack-config-for-development-a53bab71.cjs.dev.js} +24 -28
  24. package/dist/{create-webpack-config-for-development-59faaed8.cjs.prod.js → create-webpack-config-for-development-c915ec0c.cjs.prod.js} +24 -28
  25. package/dist/{create-webpack-config-for-production-b28b3d33.esm.js → create-webpack-config-for-production-342485cd.esm.js} +18 -21
  26. package/dist/{create-webpack-config-for-production-1af3a454.cjs.prod.js → create-webpack-config-for-production-af6f3138.cjs.prod.js} +20 -23
  27. package/dist/{create-webpack-config-for-production-e12e3c30.cjs.dev.js → create-webpack-config-for-production-db45d9ab.cjs.dev.js} +20 -23
  28. package/dist/{user-agent-9a470e39.cjs.dev.js → credentials-storage-a37a8915.cjs.dev.js} +24 -24
  29. package/dist/{user-agent-6e8d0e0b.cjs.prod.js → credentials-storage-b803a804.cjs.prod.js} +24 -24
  30. package/dist/{user-agent-4b60934e.esm.js → credentials-storage-cb88e8fc.esm.js} +22 -22
  31. package/dist/declarations/src/deprecated-entry-points.d.ts +1 -1
  32. package/dist/login-35040a86.cjs.dev.js +93 -0
  33. package/dist/login-6e17747d.esm.js +84 -0
  34. package/dist/login-90736d7e.cjs.prod.js +93 -0
  35. package/dist/{package-a5454c97.esm.js → package-17f18481.esm.js} +17 -16
  36. package/dist/{package-e2d9b5e0.cjs.dev.js → package-c42dc2ac.cjs.dev.js} +17 -16
  37. package/dist/{package-808a31f1.cjs.prod.js → package-db15171f.cjs.prod.js} +17 -16
  38. package/dist/{paths-76b66e74.cjs.prod.js → paths-284c77fb.cjs.prod.js} +6 -8
  39. package/dist/{paths-ed23d5a1.esm.js → paths-55c5d5a2.esm.js} +6 -8
  40. package/dist/{paths-16823f56.cjs.dev.js → paths-db35ac0f.cjs.dev.js} +6 -8
  41. package/dist/serve-41077dad.cjs.prod.js +48 -0
  42. package/dist/serve-660e2ee0.esm.js +41 -0
  43. package/dist/serve-b8063204.cjs.dev.js +48 -0
  44. package/dist/start-0aa71e9a.esm.js +166 -0
  45. package/dist/start-2e7ec87c.cjs.dev.js +180 -0
  46. package/dist/start-c0ffe8d7.cjs.prod.js +180 -0
  47. package/dist/start-vite-324af14d.cjs.prod.js +119 -0
  48. package/dist/start-vite-7d10ae71.esm.js +107 -0
  49. package/dist/start-vite-8f03b0df.cjs.dev.js +119 -0
  50. package/dist/{vendors-to-transpile-367e0ba8.cjs.prod.js → vendors-to-transpile-04a49d40.cjs.prod.js} +1 -1
  51. package/dist/{vendors-to-transpile-b51af5d3.cjs.dev.js → vendors-to-transpile-6ab4ea06.cjs.dev.js} +1 -1
  52. package/dist/{vendors-to-transpile-68e03526.esm.js → vendors-to-transpile-7dc84a72.esm.js} +1 -1
  53. package/dist/vite-plugin-svgr-9a4e7f77.cjs.prod.js +79 -0
  54. package/dist/vite-plugin-svgr-f17db78a.esm.js +55 -0
  55. package/dist/vite-plugin-svgr-fdb37ccf.cjs.dev.js +79 -0
  56. package/package.json +17 -16
  57. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.dev.js +2 -4
  58. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.prod.js +2 -4
  59. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.esm.js +2 -4
  60. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.dev.js +12 -13
  61. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.prod.js +12 -13
  62. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.esm.js +12 -13
  63. package/dist/build-0e6d74d1.esm.js +0 -209
  64. package/dist/build-9074fc85.cjs.dev.js +0 -224
  65. package/dist/build-ae132901.cjs.prod.js +0 -224
  66. package/dist/build-vite-482a21b8.cjs.dev.js +0 -151
  67. package/dist/build-vite-cc68e3bf.esm.js +0 -139
  68. package/dist/build-vite-f095b68d.cjs.prod.js +0 -151
  69. package/dist/compile-html-4361a0b3.esm.js +0 -77
  70. package/dist/compile-html-d6331c35.cjs.prod.js +0 -87
  71. package/dist/compile-html-d9e731aa.cjs.dev.js +0 -87
  72. package/dist/config-sync-2a9945bc.cjs.dev.js +0 -989
  73. package/dist/config-sync-43a80f60.cjs.prod.js +0 -984
  74. package/dist/config-sync-c6c4d1cf.esm.js +0 -964
  75. package/dist/login-7f1cc8d0.cjs.prod.js +0 -167
  76. package/dist/login-d21a49e8.esm.js +0 -157
  77. package/dist/login-ed827138.cjs.dev.js +0 -167
  78. package/dist/serve-12de323b.cjs.dev.js +0 -70
  79. package/dist/serve-784f4fcd.cjs.prod.js +0 -70
  80. package/dist/serve-d6b437b1.esm.js +0 -62
  81. package/dist/start-10a4d95a.esm.js +0 -194
  82. package/dist/start-d021fa98.cjs.prod.js +0 -209
  83. package/dist/start-eea524f2.cjs.dev.js +0 -209
  84. package/dist/start-vite-57ec5175.cjs.dev.js +0 -146
  85. package/dist/start-vite-94c2db8c.esm.js +0 -133
  86. package/dist/start-vite-fc0b15d3.cjs.prod.js +0 -146
  87. package/dist/vite-plugin-svgr-4205f2b5.cjs.dev.js +0 -110
  88. package/dist/vite-plugin-svgr-eb8524fa.esm.js +0 -85
  89. package/dist/vite-plugin-svgr-f3bbedbe.cjs.prod.js +0 -110
@@ -0,0 +1,156 @@
1
+ import _Promise from '@babel/runtime-corejs3/core-js-stable/promise';
2
+ import path from 'path';
3
+ import chalk from 'chalk';
4
+ import fs from 'fs-extra';
5
+ import checkRequiredFiles from 'react-dev-utils/checkRequiredFiles';
6
+ import FileSizeReporter from 'react-dev-utils/FileSizeReporter';
7
+ import formatWebpackMessages from 'react-dev-utils/formatWebpackMessages';
8
+ import printBuildError from 'react-dev-utils/printBuildError';
9
+ import webpack from 'webpack';
10
+ import { packageLocation } from '@commercetools-frontend/assets';
11
+ import { c as createWebpackConfigForProduction } from './create-webpack-config-for-production-342485cd.esm.js';
12
+ import { p as paths } from './paths-55c5d5a2.esm.js';
13
+ import '@babel/runtime-corejs3/core-js-stable/object/keys';
14
+ import '@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols';
15
+ import '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor';
16
+ import '@babel/runtime-corejs3/core-js-stable/instance/for-each';
17
+ import '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors';
18
+ import '@babel/runtime-corejs3/core-js-stable/object/define-properties';
19
+ import '@babel/runtime-corejs3/core-js-stable/object/define-property';
20
+ import '@babel/runtime-corejs3/helpers/defineProperty';
21
+ import '@babel/runtime-corejs3/core-js-stable/instance/filter';
22
+ import '@babel/runtime-corejs3/core-js-stable/instance/map';
23
+ import '@babel/runtime-corejs3/core-js-stable/json/stringify';
24
+ import '@babel/runtime-corejs3/core-js-stable/instance/ends-with';
25
+ import '@babel/runtime-corejs3/core-js-stable/number/is-integer';
26
+ import '@babel/runtime-corejs3/core-js-stable/instance/concat';
27
+ import 'css-minimizer-webpack-plugin';
28
+ import 'html-webpack-plugin';
29
+ import 'mini-css-extract-plugin';
30
+ import 'moment-locales-webpack-plugin';
31
+ import 'terser-webpack-plugin';
32
+ import 'webpack-bundle-analyzer';
33
+ import '@babel/runtime-corejs3/helpers/classCallCheck';
34
+ import '@babel/runtime-corejs3/helpers/createClass';
35
+ import '@babel/runtime-corejs3/core-js-stable/instance/bind';
36
+ import '@babel/runtime-corejs3/core-js-stable/instance/reduce';
37
+ import '@babel/runtime-corejs3/core-js-stable/object/assign';
38
+ import 'fs';
39
+ import './create-postcss-config-a0d4cffa.esm.js';
40
+ import '@babel/runtime-corejs3/helpers/slicedToArray';
41
+ import './package-17f18481.esm.js';
42
+ import './has-jsx-runtime-8314226e.esm.js';
43
+ import './vendors-to-transpile-7dc84a72.esm.js';
44
+ import '@babel/runtime-corejs3/core-js-stable/instance/find';
45
+
46
+ const measureFileSizesBeforeBuild = FileSizeReporter.measureFileSizesBeforeBuild;
47
+ const printFileSizesAfterBuild = FileSizeReporter.printFileSizesAfterBuild; // These sizes are pretty large. We'll warn for bundles exceeding them.
48
+
49
+ const WARN_AFTER_BUNDLE_GZIP_SIZE = 512 * 1024;
50
+ const WARN_AFTER_CHUNK_GZIP_SIZE = 1024 * 1024;
51
+
52
+ async function run() {
53
+ const hasWebpackConfig = fs.existsSync(paths.appWebpackConfig); // Warn and crash if required files are missing
54
+
55
+ if (!checkRequiredFiles([])) {
56
+ process.exit(1);
57
+ } // First, read the current file sizes in build directory.
58
+ // This lets us display how much they changed later.
59
+
60
+
61
+ const previousFileSizes = await measureFileSizesBeforeBuild(paths.appBuild); // Remove all content but keep the directory so that
62
+ // if you're in it, you don't end up in Trash
63
+
64
+ fs.emptyDirSync(paths.appBuild); // Copy default files
65
+
66
+ copyDefaultFiles();
67
+
68
+ try {
69
+ // Start the webpack build
70
+ const result = await build();
71
+
72
+ if (result.warnings.length) {
73
+ console.log(chalk.yellow('Compiled with warnings.\n'));
74
+ console.log(result.warnings.join('\n\n'));
75
+ console.log("\nSearch for the ".concat(chalk.underline(chalk.yellow('keywords')), " to learn more about each warning."));
76
+ console.log("To ignore, add ".concat(chalk.cyan('// eslint-disable-next-line'), " to the line before.\n"));
77
+ } else {
78
+ console.log(chalk.green('Compiled successfully.\n'));
79
+ }
80
+
81
+ console.log('File sizes after gzip:\n');
82
+ printFileSizesAfterBuild(result.stats, previousFileSizes, paths.appBuild, WARN_AFTER_BUNDLE_GZIP_SIZE, WARN_AFTER_CHUNK_GZIP_SIZE);
83
+ console.log();
84
+ } catch (error) {
85
+ if (error instanceof Error) {
86
+ printBuildError(error);
87
+ }
88
+
89
+ throw new Error("Failed to compile");
90
+ } // Create the production build and print the deployment instructions.
91
+
92
+
93
+ async function build() {
94
+ console.log('Creating an optimized production build...');
95
+ const config = hasWebpackConfig ? require(paths.appWebpackConfig) : createWebpackConfigForProduction();
96
+ const compiler = webpack(config);
97
+ return new _Promise((resolve, reject) => {
98
+ compiler.run((err, stats) => {
99
+ let messages;
100
+
101
+ if (err) {
102
+ if (!err.message) {
103
+ return reject(err);
104
+ }
105
+
106
+ let errMessage = err.message; // Add additional information for postcss errors
107
+
108
+ if (Object.prototype.hasOwnProperty.call(err, 'postcssNode')) {
109
+ errMessage += '\nCompileError: Begins at CSS selector ' + // @ts-ignore
110
+ err['postcssNode'].selector;
111
+ }
112
+
113
+ messages = formatWebpackMessages({
114
+ // @ts-ignore
115
+ errors: [errMessage],
116
+ warnings: []
117
+ });
118
+ } else {
119
+ messages = formatWebpackMessages(stats === null || stats === void 0 ? void 0 : stats.toJson({
120
+ all: false,
121
+ warnings: true,
122
+ errors: true
123
+ }));
124
+ }
125
+
126
+ if (messages.errors.length) {
127
+ // Only keep the first error. Others are often indicative
128
+ // of the same problem, but confuse the reader with noise.
129
+ if (messages.errors.length > 1) {
130
+ messages.errors.length = 1;
131
+ }
132
+
133
+ return reject(new Error(messages.errors.join('\n\n')));
134
+ }
135
+
136
+ if (process.env.CI && (typeof process.env.CI !== 'string' || process.env.CI.toLowerCase() !== 'false') && messages.warnings.length) {
137
+ console.log(chalk.yellow('\nTreating warnings as errors because process.env.CI = true.\n' + 'Most CI servers set it automatically.\n'));
138
+ return reject(new Error(messages.warnings.join('\n\n')));
139
+ }
140
+
141
+ return resolve({
142
+ stats: stats,
143
+ warnings: messages.warnings
144
+ });
145
+ });
146
+ });
147
+ }
148
+
149
+ function copyDefaultFiles() {
150
+ fs.copySync(path.join(packageLocation, 'html-page'), paths.appBuild, {
151
+ dereference: true
152
+ });
153
+ }
154
+ }
155
+
156
+ export { run as default };
@@ -0,0 +1,170 @@
1
+ 'use strict';
2
+
3
+ var _Promise = require('@babel/runtime-corejs3/core-js-stable/promise');
4
+ var path = require('path');
5
+ var chalk = require('chalk');
6
+ var fs = require('fs-extra');
7
+ var checkRequiredFiles = require('react-dev-utils/checkRequiredFiles');
8
+ var FileSizeReporter = require('react-dev-utils/FileSizeReporter');
9
+ var formatWebpackMessages = require('react-dev-utils/formatWebpackMessages');
10
+ var printBuildError = require('react-dev-utils/printBuildError');
11
+ var webpack = require('webpack');
12
+ var assets = require('@commercetools-frontend/assets');
13
+ var createWebpackConfigForProduction = require('./create-webpack-config-for-production-db45d9ab.cjs.dev.js');
14
+ var paths = require('./paths-db35ac0f.cjs.dev.js');
15
+ require('@babel/runtime-corejs3/core-js-stable/object/keys');
16
+ require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
17
+ require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
18
+ require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
19
+ require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
20
+ require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
21
+ require('@babel/runtime-corejs3/core-js-stable/object/define-property');
22
+ require('@babel/runtime-corejs3/helpers/defineProperty');
23
+ require('@babel/runtime-corejs3/core-js-stable/instance/filter');
24
+ require('@babel/runtime-corejs3/core-js-stable/instance/map');
25
+ require('@babel/runtime-corejs3/core-js-stable/json/stringify');
26
+ require('@babel/runtime-corejs3/core-js-stable/instance/ends-with');
27
+ require('@babel/runtime-corejs3/core-js-stable/number/is-integer');
28
+ require('@babel/runtime-corejs3/core-js-stable/instance/concat');
29
+ require('css-minimizer-webpack-plugin');
30
+ require('html-webpack-plugin');
31
+ require('mini-css-extract-plugin');
32
+ require('moment-locales-webpack-plugin');
33
+ require('terser-webpack-plugin');
34
+ require('webpack-bundle-analyzer');
35
+ require('@babel/runtime-corejs3/helpers/classCallCheck');
36
+ require('@babel/runtime-corejs3/helpers/createClass');
37
+ require('@babel/runtime-corejs3/core-js-stable/instance/bind');
38
+ require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
39
+ require('@babel/runtime-corejs3/core-js-stable/object/assign');
40
+ require('fs');
41
+ require('./create-postcss-config-5cc679d5.cjs.dev.js');
42
+ require('@babel/runtime-corejs3/helpers/slicedToArray');
43
+ require('./package-c42dc2ac.cjs.dev.js');
44
+ require('./has-jsx-runtime-3d4bb633.cjs.dev.js');
45
+ require('./vendors-to-transpile-6ab4ea06.cjs.dev.js');
46
+ require('@babel/runtime-corejs3/core-js-stable/instance/find');
47
+
48
+ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
49
+
50
+ var _Promise__default = /*#__PURE__*/_interopDefault(_Promise);
51
+ var path__default = /*#__PURE__*/_interopDefault(path);
52
+ var chalk__default = /*#__PURE__*/_interopDefault(chalk);
53
+ var fs__default = /*#__PURE__*/_interopDefault(fs);
54
+ var checkRequiredFiles__default = /*#__PURE__*/_interopDefault(checkRequiredFiles);
55
+ var FileSizeReporter__default = /*#__PURE__*/_interopDefault(FileSizeReporter);
56
+ var formatWebpackMessages__default = /*#__PURE__*/_interopDefault(formatWebpackMessages);
57
+ var printBuildError__default = /*#__PURE__*/_interopDefault(printBuildError);
58
+ var webpack__default = /*#__PURE__*/_interopDefault(webpack);
59
+
60
+ const measureFileSizesBeforeBuild = FileSizeReporter__default["default"].measureFileSizesBeforeBuild;
61
+ const printFileSizesAfterBuild = FileSizeReporter__default["default"].printFileSizesAfterBuild; // These sizes are pretty large. We'll warn for bundles exceeding them.
62
+
63
+ const WARN_AFTER_BUNDLE_GZIP_SIZE = 512 * 1024;
64
+ const WARN_AFTER_CHUNK_GZIP_SIZE = 1024 * 1024;
65
+
66
+ async function run() {
67
+ const hasWebpackConfig = fs__default["default"].existsSync(paths.paths.appWebpackConfig); // Warn and crash if required files are missing
68
+
69
+ if (!checkRequiredFiles__default["default"]([])) {
70
+ process.exit(1);
71
+ } // First, read the current file sizes in build directory.
72
+ // This lets us display how much they changed later.
73
+
74
+
75
+ const previousFileSizes = await measureFileSizesBeforeBuild(paths.paths.appBuild); // Remove all content but keep the directory so that
76
+ // if you're in it, you don't end up in Trash
77
+
78
+ fs__default["default"].emptyDirSync(paths.paths.appBuild); // Copy default files
79
+
80
+ copyDefaultFiles();
81
+
82
+ try {
83
+ // Start the webpack build
84
+ const result = await build();
85
+
86
+ if (result.warnings.length) {
87
+ console.log(chalk__default["default"].yellow('Compiled with warnings.\n'));
88
+ console.log(result.warnings.join('\n\n'));
89
+ console.log("\nSearch for the ".concat(chalk__default["default"].underline(chalk__default["default"].yellow('keywords')), " to learn more about each warning."));
90
+ console.log("To ignore, add ".concat(chalk__default["default"].cyan('// eslint-disable-next-line'), " to the line before.\n"));
91
+ } else {
92
+ console.log(chalk__default["default"].green('Compiled successfully.\n'));
93
+ }
94
+
95
+ console.log('File sizes after gzip:\n');
96
+ printFileSizesAfterBuild(result.stats, previousFileSizes, paths.paths.appBuild, WARN_AFTER_BUNDLE_GZIP_SIZE, WARN_AFTER_CHUNK_GZIP_SIZE);
97
+ console.log();
98
+ } catch (error) {
99
+ if (error instanceof Error) {
100
+ printBuildError__default["default"](error);
101
+ }
102
+
103
+ throw new Error("Failed to compile");
104
+ } // Create the production build and print the deployment instructions.
105
+
106
+
107
+ async function build() {
108
+ console.log('Creating an optimized production build...');
109
+ const config = hasWebpackConfig ? require(paths.paths.appWebpackConfig) : createWebpackConfigForProduction.createWebpackConfigForProduction();
110
+ const compiler = webpack__default["default"](config);
111
+ return new _Promise__default["default"]((resolve, reject) => {
112
+ compiler.run((err, stats) => {
113
+ let messages;
114
+
115
+ if (err) {
116
+ if (!err.message) {
117
+ return reject(err);
118
+ }
119
+
120
+ let errMessage = err.message; // Add additional information for postcss errors
121
+
122
+ if (Object.prototype.hasOwnProperty.call(err, 'postcssNode')) {
123
+ errMessage += '\nCompileError: Begins at CSS selector ' + // @ts-ignore
124
+ err['postcssNode'].selector;
125
+ }
126
+
127
+ messages = formatWebpackMessages__default["default"]({
128
+ // @ts-ignore
129
+ errors: [errMessage],
130
+ warnings: []
131
+ });
132
+ } else {
133
+ messages = formatWebpackMessages__default["default"](stats === null || stats === void 0 ? void 0 : stats.toJson({
134
+ all: false,
135
+ warnings: true,
136
+ errors: true
137
+ }));
138
+ }
139
+
140
+ if (messages.errors.length) {
141
+ // Only keep the first error. Others are often indicative
142
+ // of the same problem, but confuse the reader with noise.
143
+ if (messages.errors.length > 1) {
144
+ messages.errors.length = 1;
145
+ }
146
+
147
+ return reject(new Error(messages.errors.join('\n\n')));
148
+ }
149
+
150
+ if (process.env.CI && (typeof process.env.CI !== 'string' || process.env.CI.toLowerCase() !== 'false') && messages.warnings.length) {
151
+ console.log(chalk__default["default"].yellow('\nTreating warnings as errors because process.env.CI = true.\n' + 'Most CI servers set it automatically.\n'));
152
+ return reject(new Error(messages.warnings.join('\n\n')));
153
+ }
154
+
155
+ return resolve({
156
+ stats: stats,
157
+ warnings: messages.warnings
158
+ });
159
+ });
160
+ });
161
+ }
162
+
163
+ function copyDefaultFiles() {
164
+ fs__default["default"].copySync(path__default["default"].join(assets.packageLocation, 'html-page'), paths.paths.appBuild, {
165
+ dereference: true
166
+ });
167
+ }
168
+ }
169
+
170
+ exports["default"] = run;
@@ -0,0 +1,118 @@
1
+ import _parseInt from '@babel/runtime-corejs3/core-js-stable/parse-int';
2
+ import _JSON$stringify from '@babel/runtime-corejs3/core-js-stable/json/stringify';
3
+ import path from 'path';
4
+ import pluginGraphql from '@rollup/plugin-graphql';
5
+ import pluginReact from '@vitejs/plugin-react';
6
+ import fs from 'fs-extra';
7
+ import { build } from 'vite';
8
+ import { packageLocation } from '@commercetools-frontend/assets';
9
+ import { generateTemplate } from '@commercetools-frontend/mc-html-template';
10
+ import { p as paths } from './paths-55c5d5a2.esm.js';
11
+ import { v as vitePluginSvgr } from './vite-plugin-svgr-f17db78a.esm.js';
12
+ import '@babel/runtime-corejs3/core-js-stable/instance/find';
13
+ import '@babel/runtime-corejs3/core-js-stable/instance/concat';
14
+ import 'fs';
15
+ import '@rollup/pluginutils';
16
+
17
+ // This script/function is injected into the `index.html` and used by Vite
18
+ // on runtime to build the assets URL (for example when using a separate CDN for the assets).
19
+ // Inspired by https://github.com/vitejs/vite/blob/main/playground/assets/vite.config-runtime-base.js
20
+ const dynamicBaseAssetsCode = "globalThis.__toCdnUrl = filePath => window.app.cdnUrl.replace(/\\/$/, '') + '/' + filePath;";
21
+
22
+ function vitePluginDynamicBaseAssetsGlobals() {
23
+ return {
24
+ name: 'dynamic-base-assets-globals',
25
+
26
+ transformIndexHtml(html, ctx) {
27
+ if (ctx.bundle) {
28
+ // Only inject during build
29
+ return [{
30
+ tag: 'script',
31
+ attrs: {
32
+ type: 'module'
33
+ },
34
+ children: dynamicBaseAssetsCode
35
+ }];
36
+ }
37
+
38
+ return html;
39
+ }
40
+
41
+ };
42
+ }
43
+
44
+ async function run() {
45
+ const DEFAULT_PORT = _parseInt(String(process.env.HTTP_PORT), 10) || 3001; // Ensure the `/public` folder exists.
46
+
47
+ fs.mkdirSync(paths.appBuild, {
48
+ recursive: true
49
+ }); // Generate `index.html` (template).
50
+
51
+ const appEntryPoint = path.relative(paths.appRoot, paths.entryPoint);
52
+ const html = generateTemplate({
53
+ // Define the module entry point (path relative from the `/public` folder).
54
+ // NOTE: that this is different from the development configuration.
55
+ scriptImports: ["<script type=\"module\" src=\"/".concat(appEntryPoint, "\"></script>")]
56
+ }); // Write `index.html` (template) into the `/public` folder.
57
+
58
+ fs.writeFileSync(paths.appIndexHtml, html, {
59
+ encoding: 'utf8'
60
+ });
61
+ await build({
62
+ root: paths.appRoot,
63
+ base: './',
64
+ // <-- Important to allow configuring the runtime base path.
65
+ define: {
66
+ 'process.env.DEBUG': _JSON$stringify(false),
67
+ 'process.env.NODE_ENV': _JSON$stringify('production')
68
+ },
69
+ build: {
70
+ outDir: 'public',
71
+ rollupOptions: {
72
+ // This is necessary to instruct Vite that the `index.html` (template)
73
+ // is located in the `/public` folder.
74
+ // NOTE that after the build, Vite will write the `index.html` (template)
75
+ // at the `/public/public/index.html` location. See `fs.renameSync` below.
76
+ input: paths.appIndexHtml
77
+ }
78
+ },
79
+ server: {
80
+ port: DEFAULT_PORT
81
+ },
82
+ experimental: {
83
+ // https://vitejs.dev/guide/build.html#advanced-base-options
84
+ renderBuiltUrl(filename, _ref) {
85
+ let hostType = _ref.hostType;
86
+
87
+ if (hostType === 'html') {
88
+ return "__CDN_URL__".concat(filename);
89
+ }
90
+
91
+ return {
92
+ runtime: "window.__toCdnUrl(".concat(_JSON$stringify(filename), ")")
93
+ };
94
+ }
95
+
96
+ },
97
+ plugins: [pluginGraphql(), pluginReact({
98
+ jsxImportSource: '@emotion/react',
99
+ babel: {
100
+ plugins: ['@emotion/babel-plugin', '@babel/plugin-proposal-do-expressions']
101
+ }
102
+ }), vitePluginSvgr(), vitePluginDynamicBaseAssetsGlobals()]
103
+ }); // Rename `/public/public/index.html` to `/public/index.html.template`
104
+
105
+ fs.renameSync( // Because of our custom entry point path (`/public/index.html`),
106
+ // Vite will write the `index.html` to `/public/public/index.html`.
107
+ // We need to move this file to the `/public` folder and rename it
108
+ // to `index.html.template` (as expected by the `compile-html` command).
109
+ path.join(paths.appBuild, 'public/index.html'), paths.appIndexHtmlTemplate); // Clean up nested folder
110
+
111
+ fs.rmdirSync(path.join(paths.appBuild, 'public')); // Copy public assets
112
+
113
+ fs.copySync(path.join(packageLocation, 'html-page'), paths.appBuild, {
114
+ dereference: true
115
+ });
116
+ }
117
+
118
+ export { run as default };
@@ -0,0 +1,129 @@
1
+ 'use strict';
2
+
3
+ var _parseInt = require('@babel/runtime-corejs3/core-js-stable/parse-int');
4
+ var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
5
+ var path = require('path');
6
+ var pluginGraphql = require('@rollup/plugin-graphql');
7
+ var pluginReact = require('@vitejs/plugin-react');
8
+ var fs = require('fs-extra');
9
+ var vite = require('vite');
10
+ var assets = require('@commercetools-frontend/assets');
11
+ var mcHtmlTemplate = require('@commercetools-frontend/mc-html-template');
12
+ var paths = require('./paths-db35ac0f.cjs.dev.js');
13
+ var vitePluginSvgr = require('./vite-plugin-svgr-fdb37ccf.cjs.dev.js');
14
+ require('@babel/runtime-corejs3/core-js-stable/instance/find');
15
+ require('@babel/runtime-corejs3/core-js-stable/instance/concat');
16
+ require('fs');
17
+ require('@rollup/pluginutils');
18
+
19
+ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
20
+
21
+ var _parseInt__default = /*#__PURE__*/_interopDefault(_parseInt);
22
+ var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
23
+ var path__default = /*#__PURE__*/_interopDefault(path);
24
+ var pluginGraphql__default = /*#__PURE__*/_interopDefault(pluginGraphql);
25
+ var pluginReact__default = /*#__PURE__*/_interopDefault(pluginReact);
26
+ var fs__default = /*#__PURE__*/_interopDefault(fs);
27
+
28
+ // This script/function is injected into the `index.html` and used by Vite
29
+ // on runtime to build the assets URL (for example when using a separate CDN for the assets).
30
+ // Inspired by https://github.com/vitejs/vite/blob/main/playground/assets/vite.config-runtime-base.js
31
+ const dynamicBaseAssetsCode = "globalThis.__toCdnUrl = filePath => window.app.cdnUrl.replace(/\\/$/, '') + '/' + filePath;";
32
+
33
+ function vitePluginDynamicBaseAssetsGlobals() {
34
+ return {
35
+ name: 'dynamic-base-assets-globals',
36
+
37
+ transformIndexHtml(html, ctx) {
38
+ if (ctx.bundle) {
39
+ // Only inject during build
40
+ return [{
41
+ tag: 'script',
42
+ attrs: {
43
+ type: 'module'
44
+ },
45
+ children: dynamicBaseAssetsCode
46
+ }];
47
+ }
48
+
49
+ return html;
50
+ }
51
+
52
+ };
53
+ }
54
+
55
+ async function run() {
56
+ const DEFAULT_PORT = _parseInt__default["default"](String(process.env.HTTP_PORT), 10) || 3001; // Ensure the `/public` folder exists.
57
+
58
+ fs__default["default"].mkdirSync(paths.paths.appBuild, {
59
+ recursive: true
60
+ }); // Generate `index.html` (template).
61
+
62
+ const appEntryPoint = path__default["default"].relative(paths.paths.appRoot, paths.paths.entryPoint);
63
+ const html = mcHtmlTemplate.generateTemplate({
64
+ // Define the module entry point (path relative from the `/public` folder).
65
+ // NOTE: that this is different from the development configuration.
66
+ scriptImports: ["<script type=\"module\" src=\"/".concat(appEntryPoint, "\"></script>")]
67
+ }); // Write `index.html` (template) into the `/public` folder.
68
+
69
+ fs__default["default"].writeFileSync(paths.paths.appIndexHtml, html, {
70
+ encoding: 'utf8'
71
+ });
72
+ await vite.build({
73
+ root: paths.paths.appRoot,
74
+ base: './',
75
+ // <-- Important to allow configuring the runtime base path.
76
+ define: {
77
+ 'process.env.DEBUG': _JSON$stringify__default["default"](false),
78
+ 'process.env.NODE_ENV': _JSON$stringify__default["default"]('production')
79
+ },
80
+ build: {
81
+ outDir: 'public',
82
+ rollupOptions: {
83
+ // This is necessary to instruct Vite that the `index.html` (template)
84
+ // is located in the `/public` folder.
85
+ // NOTE that after the build, Vite will write the `index.html` (template)
86
+ // at the `/public/public/index.html` location. See `fs.renameSync` below.
87
+ input: paths.paths.appIndexHtml
88
+ }
89
+ },
90
+ server: {
91
+ port: DEFAULT_PORT
92
+ },
93
+ experimental: {
94
+ // https://vitejs.dev/guide/build.html#advanced-base-options
95
+ renderBuiltUrl(filename, _ref) {
96
+ let hostType = _ref.hostType;
97
+
98
+ if (hostType === 'html') {
99
+ return "__CDN_URL__".concat(filename);
100
+ }
101
+
102
+ return {
103
+ runtime: "window.__toCdnUrl(".concat(_JSON$stringify__default["default"](filename), ")")
104
+ };
105
+ }
106
+
107
+ },
108
+ plugins: [pluginGraphql__default["default"](), pluginReact__default["default"]({
109
+ jsxImportSource: '@emotion/react',
110
+ babel: {
111
+ plugins: ['@emotion/babel-plugin', '@babel/plugin-proposal-do-expressions']
112
+ }
113
+ }), vitePluginSvgr.vitePluginSvgr(), vitePluginDynamicBaseAssetsGlobals()]
114
+ }); // Rename `/public/public/index.html` to `/public/index.html.template`
115
+
116
+ fs__default["default"].renameSync( // Because of our custom entry point path (`/public/index.html`),
117
+ // Vite will write the `index.html` to `/public/public/index.html`.
118
+ // We need to move this file to the `/public` folder and rename it
119
+ // to `index.html.template` (as expected by the `compile-html` command).
120
+ path__default["default"].join(paths.paths.appBuild, 'public/index.html'), paths.paths.appIndexHtmlTemplate); // Clean up nested folder
121
+
122
+ fs__default["default"].rmdirSync(path__default["default"].join(paths.paths.appBuild, 'public')); // Copy public assets
123
+
124
+ fs__default["default"].copySync(path__default["default"].join(assets.packageLocation, 'html-page'), paths.paths.appBuild, {
125
+ dereference: true
126
+ });
127
+ }
128
+
129
+ exports["default"] = run;