@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
@@ -1,146 +0,0 @@
1
- 'use strict';
2
-
3
- var _asyncToGenerator = require('@babel/runtime-corejs3/helpers/asyncToGenerator');
4
- var _regeneratorRuntime = require('@babel/runtime-corejs3/regenerator');
5
- var _parseInt = require('@babel/runtime-corejs3/core-js-stable/parse-int');
6
- var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
7
- var fs = require('fs-extra');
8
- var path = require('path');
9
- var vite = require('vite');
10
- var pluginGraphql = require('@rollup/plugin-graphql');
11
- var pluginReact = require('@vitejs/plugin-react-swc');
12
- var applicationConfig = require('@commercetools-frontend/application-config');
13
- var mcHtmlTemplate = require('@commercetools-frontend/mc-html-template');
14
- var assets = require('@commercetools-frontend/assets');
15
- var paths = require('./paths-16823f56.cjs.dev.js');
16
- var _Object$assign = require('@babel/runtime-corejs3/core-js-stable/object/assign');
17
- var mcDevAuthentication = require('@commercetools-frontend/mc-dev-authentication');
18
- var vitePluginSvgr = require('./vite-plugin-svgr-4205f2b5.cjs.dev.js');
19
- require('@babel/runtime-corejs3/core-js-stable/instance/find');
20
- require('@babel/runtime-corejs3/core-js-stable/instance/concat');
21
- require('fs');
22
- require('@rollup/pluginutils');
23
-
24
- function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
25
-
26
- var _regeneratorRuntime__default = /*#__PURE__*/_interopDefault(_regeneratorRuntime);
27
- var _parseInt__default = /*#__PURE__*/_interopDefault(_parseInt);
28
- var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
29
- var fs__default = /*#__PURE__*/_interopDefault(fs);
30
- var path__default = /*#__PURE__*/_interopDefault(path);
31
- var pluginGraphql__default = /*#__PURE__*/_interopDefault(pluginGraphql);
32
- var pluginReact__default = /*#__PURE__*/_interopDefault(pluginReact);
33
- var _Object$assign__default = /*#__PURE__*/_interopDefault(_Object$assign);
34
-
35
- var vitePluginCustomApplication = function vitePluginCustomApplication(applicationConfig) {
36
- return {
37
- name: 'custom-application',
38
- configureServer: function configureServer(server) {
39
- return function () {
40
- // Users do not need to have/maintain the `index.html` (as expected by Vite)
41
- // as it's generated and maintained by the Custom Application CLI.
42
- // Therefore, the generated `index.html` (template) is written into the `/public`
43
- // folder so that it's gitignored.
44
- // As a result, we need to make sure to point the URI path to the correct location.
45
- server.middlewares.use(function (req, _res, next) {
46
- if (req.url === '/index.html') {
47
- req.url = '/public/index.html';
48
- }
49
-
50
- next();
51
- }); // Handle auth routes for internal local development.
52
-
53
- server.middlewares.use(mcDevAuthentication.createMcDevAuthenticationMiddleware(applicationConfig));
54
- };
55
- },
56
-
57
- /**
58
- * @type {import('vite').IndexHtmlTransformHook}
59
- */
60
- transformIndexHtml: function transformIndexHtml(rawHtml, _ctx) {
61
- var compiledHeaders = mcHtmlTemplate.processHeaders(applicationConfig);
62
-
63
- var enhancedLocalEnv = _Object$assign__default["default"]({}, applicationConfig.env, // Now that the app config is defined as a `env.json`, when we start the FE app
64
- // to point to the local backend API by passing the `MC_API_URL` env does not
65
- // work anymore). To make it work again, we can override the `env.json` config
66
- // with the env variable before injecting the values into the index.html.
67
- // NOTE: this is only necessary for development.
68
- process.env.MC_API_URL ? {
69
- mcApiUrl: process.env.MC_API_URL
70
- } : {}); // Resolve the placeholders of the `index.html` (template) file, before serving it.
71
-
72
-
73
- var html = mcHtmlTemplate.replaceHtmlPlaceholders(rawHtml, {
74
- env: enhancedLocalEnv,
75
- headers: compiledHeaders
76
- });
77
- return html;
78
- }
79
- };
80
- };
81
-
82
- function run() {
83
- return _run.apply(this, arguments);
84
- }
85
-
86
- function _run() {
87
- _run = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee() {
88
- var DEFAULT_PORT, applicationConfig$1, appEntryPoint, html, server;
89
- return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
90
- while (1) {
91
- switch (_context.prev = _context.next) {
92
- case 0:
93
- DEFAULT_PORT = _parseInt__default["default"](String(process.env.HTTP_PORT), 10) || 3001; // Load the Custom Application config file first.
94
-
95
- applicationConfig$1 = applicationConfig.processConfig(); // Ensure the `/public` folder exists.
96
-
97
- fs__default["default"].mkdirSync(paths.paths.appBuild, {
98
- recursive: true
99
- }); // Generate `index.html` (template).
100
-
101
- appEntryPoint = path__default["default"].relative(paths.paths.appRoot, paths.paths.entryPoint);
102
- html = mcHtmlTemplate.generateTemplate({
103
- // Define the module entry point (path relative to the `/public` folder).
104
- // NOTE: that this is different from the production configuration.
105
- scriptImports: ["<script type=\"module\" src=\"/../".concat(appEntryPoint, "\"></script>")]
106
- }); // Write `index.html` (template) into the `/public` folder.
107
-
108
- fs__default["default"].writeFileSync(paths.paths.appIndexHtml, html, {
109
- encoding: 'utf8'
110
- });
111
- _context.next = 8;
112
- return vite.createServer({
113
- root: paths.paths.appRoot,
114
- define: {
115
- 'process.env.DEBUG': _JSON$stringify__default["default"](false),
116
- 'process.env.NODE_ENV': _JSON$stringify__default["default"]('development')
117
- },
118
- server: {
119
- port: DEFAULT_PORT
120
- },
121
- plugins: [pluginGraphql__default["default"](), pluginReact__default["default"](), vitePluginSvgr.vitePluginSvgr(), vitePluginCustomApplication(applicationConfig$1)]
122
- });
123
-
124
- case 8:
125
- server = _context.sent;
126
- _context.next = 11;
127
- return server.listen();
128
-
129
- case 11:
130
- // Copy public assets to `/public` folder (even in development).
131
- fs__default["default"].copySync(path__default["default"].join(assets.packageLocation, 'html-page'), paths.paths.appBuild, {
132
- dereference: true
133
- });
134
- server.printUrls();
135
-
136
- case 13:
137
- case "end":
138
- return _context.stop();
139
- }
140
- }
141
- }, _callee);
142
- }));
143
- return _run.apply(this, arguments);
144
- }
145
-
146
- exports["default"] = run;
@@ -1,133 +0,0 @@
1
- import _asyncToGenerator from '@babel/runtime-corejs3/helpers/esm/asyncToGenerator';
2
- import _regeneratorRuntime from '@babel/runtime-corejs3/regenerator';
3
- import _parseInt from '@babel/runtime-corejs3/core-js-stable/parse-int';
4
- import _JSON$stringify from '@babel/runtime-corejs3/core-js-stable/json/stringify';
5
- import fs from 'fs-extra';
6
- import path from 'path';
7
- import { createServer } from 'vite';
8
- import pluginGraphql from '@rollup/plugin-graphql';
9
- import pluginReact from '@vitejs/plugin-react-swc';
10
- import { processConfig } from '@commercetools-frontend/application-config';
11
- import { processHeaders, replaceHtmlPlaceholders, generateTemplate } from '@commercetools-frontend/mc-html-template';
12
- import { packageLocation } from '@commercetools-frontend/assets';
13
- import { p as paths } from './paths-ed23d5a1.esm.js';
14
- import _Object$assign from '@babel/runtime-corejs3/core-js-stable/object/assign';
15
- import { createMcDevAuthenticationMiddleware } from '@commercetools-frontend/mc-dev-authentication';
16
- import { v as vitePluginSvgr } from './vite-plugin-svgr-eb8524fa.esm.js';
17
- import '@babel/runtime-corejs3/core-js-stable/instance/find';
18
- import '@babel/runtime-corejs3/core-js-stable/instance/concat';
19
- import 'fs';
20
- import '@rollup/pluginutils';
21
-
22
- var vitePluginCustomApplication = function vitePluginCustomApplication(applicationConfig) {
23
- return {
24
- name: 'custom-application',
25
- configureServer: function configureServer(server) {
26
- return function () {
27
- // Users do not need to have/maintain the `index.html` (as expected by Vite)
28
- // as it's generated and maintained by the Custom Application CLI.
29
- // Therefore, the generated `index.html` (template) is written into the `/public`
30
- // folder so that it's gitignored.
31
- // As a result, we need to make sure to point the URI path to the correct location.
32
- server.middlewares.use(function (req, _res, next) {
33
- if (req.url === '/index.html') {
34
- req.url = '/public/index.html';
35
- }
36
-
37
- next();
38
- }); // Handle auth routes for internal local development.
39
-
40
- server.middlewares.use(createMcDevAuthenticationMiddleware(applicationConfig));
41
- };
42
- },
43
-
44
- /**
45
- * @type {import('vite').IndexHtmlTransformHook}
46
- */
47
- transformIndexHtml: function transformIndexHtml(rawHtml, _ctx) {
48
- var compiledHeaders = processHeaders(applicationConfig);
49
-
50
- var enhancedLocalEnv = _Object$assign({}, applicationConfig.env, // Now that the app config is defined as a `env.json`, when we start the FE app
51
- // to point to the local backend API by passing the `MC_API_URL` env does not
52
- // work anymore). To make it work again, we can override the `env.json` config
53
- // with the env variable before injecting the values into the index.html.
54
- // NOTE: this is only necessary for development.
55
- process.env.MC_API_URL ? {
56
- mcApiUrl: process.env.MC_API_URL
57
- } : {}); // Resolve the placeholders of the `index.html` (template) file, before serving it.
58
-
59
-
60
- var html = replaceHtmlPlaceholders(rawHtml, {
61
- env: enhancedLocalEnv,
62
- headers: compiledHeaders
63
- });
64
- return html;
65
- }
66
- };
67
- };
68
-
69
- function run() {
70
- return _run.apply(this, arguments);
71
- }
72
-
73
- function _run() {
74
- _run = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
75
- var DEFAULT_PORT, applicationConfig, appEntryPoint, html, server;
76
- return _regeneratorRuntime.wrap(function _callee$(_context) {
77
- while (1) {
78
- switch (_context.prev = _context.next) {
79
- case 0:
80
- DEFAULT_PORT = _parseInt(String(process.env.HTTP_PORT), 10) || 3001; // Load the Custom Application config file first.
81
-
82
- applicationConfig = processConfig(); // Ensure the `/public` folder exists.
83
-
84
- fs.mkdirSync(paths.appBuild, {
85
- recursive: true
86
- }); // Generate `index.html` (template).
87
-
88
- appEntryPoint = path.relative(paths.appRoot, paths.entryPoint);
89
- html = generateTemplate({
90
- // Define the module entry point (path relative to the `/public` folder).
91
- // NOTE: that this is different from the production configuration.
92
- scriptImports: ["<script type=\"module\" src=\"/../".concat(appEntryPoint, "\"></script>")]
93
- }); // Write `index.html` (template) into the `/public` folder.
94
-
95
- fs.writeFileSync(paths.appIndexHtml, html, {
96
- encoding: 'utf8'
97
- });
98
- _context.next = 8;
99
- return createServer({
100
- root: paths.appRoot,
101
- define: {
102
- 'process.env.DEBUG': _JSON$stringify(false),
103
- 'process.env.NODE_ENV': _JSON$stringify('development')
104
- },
105
- server: {
106
- port: DEFAULT_PORT
107
- },
108
- plugins: [pluginGraphql(), pluginReact(), vitePluginSvgr(), vitePluginCustomApplication(applicationConfig)]
109
- });
110
-
111
- case 8:
112
- server = _context.sent;
113
- _context.next = 11;
114
- return server.listen();
115
-
116
- case 11:
117
- // Copy public assets to `/public` folder (even in development).
118
- fs.copySync(path.join(packageLocation, 'html-page'), paths.appBuild, {
119
- dereference: true
120
- });
121
- server.printUrls();
122
-
123
- case 13:
124
- case "end":
125
- return _context.stop();
126
- }
127
- }
128
- }, _callee);
129
- }));
130
- return _run.apply(this, arguments);
131
- }
132
-
133
- export { run as default };
@@ -1,146 +0,0 @@
1
- 'use strict';
2
-
3
- var _asyncToGenerator = require('@babel/runtime-corejs3/helpers/asyncToGenerator');
4
- var _regeneratorRuntime = require('@babel/runtime-corejs3/regenerator');
5
- var _parseInt = require('@babel/runtime-corejs3/core-js-stable/parse-int');
6
- var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
7
- var fs = require('fs-extra');
8
- var path = require('path');
9
- var vite = require('vite');
10
- var pluginGraphql = require('@rollup/plugin-graphql');
11
- var pluginReact = require('@vitejs/plugin-react-swc');
12
- var applicationConfig = require('@commercetools-frontend/application-config');
13
- var mcHtmlTemplate = require('@commercetools-frontend/mc-html-template');
14
- var assets = require('@commercetools-frontend/assets');
15
- var paths = require('./paths-76b66e74.cjs.prod.js');
16
- var _Object$assign = require('@babel/runtime-corejs3/core-js-stable/object/assign');
17
- var mcDevAuthentication = require('@commercetools-frontend/mc-dev-authentication');
18
- var vitePluginSvgr = require('./vite-plugin-svgr-f3bbedbe.cjs.prod.js');
19
- require('@babel/runtime-corejs3/core-js-stable/instance/find');
20
- require('@babel/runtime-corejs3/core-js-stable/instance/concat');
21
- require('fs');
22
- require('@rollup/pluginutils');
23
-
24
- function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
25
-
26
- var _regeneratorRuntime__default = /*#__PURE__*/_interopDefault(_regeneratorRuntime);
27
- var _parseInt__default = /*#__PURE__*/_interopDefault(_parseInt);
28
- var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
29
- var fs__default = /*#__PURE__*/_interopDefault(fs);
30
- var path__default = /*#__PURE__*/_interopDefault(path);
31
- var pluginGraphql__default = /*#__PURE__*/_interopDefault(pluginGraphql);
32
- var pluginReact__default = /*#__PURE__*/_interopDefault(pluginReact);
33
- var _Object$assign__default = /*#__PURE__*/_interopDefault(_Object$assign);
34
-
35
- var vitePluginCustomApplication = function vitePluginCustomApplication(applicationConfig) {
36
- return {
37
- name: 'custom-application',
38
- configureServer: function configureServer(server) {
39
- return function () {
40
- // Users do not need to have/maintain the `index.html` (as expected by Vite)
41
- // as it's generated and maintained by the Custom Application CLI.
42
- // Therefore, the generated `index.html` (template) is written into the `/public`
43
- // folder so that it's gitignored.
44
- // As a result, we need to make sure to point the URI path to the correct location.
45
- server.middlewares.use(function (req, _res, next) {
46
- if (req.url === '/index.html') {
47
- req.url = '/public/index.html';
48
- }
49
-
50
- next();
51
- }); // Handle auth routes for internal local development.
52
-
53
- server.middlewares.use(mcDevAuthentication.createMcDevAuthenticationMiddleware(applicationConfig));
54
- };
55
- },
56
-
57
- /**
58
- * @type {import('vite').IndexHtmlTransformHook}
59
- */
60
- transformIndexHtml: function transformIndexHtml(rawHtml, _ctx) {
61
- var compiledHeaders = mcHtmlTemplate.processHeaders(applicationConfig);
62
-
63
- var enhancedLocalEnv = _Object$assign__default["default"]({}, applicationConfig.env, // Now that the app config is defined as a `env.json`, when we start the FE app
64
- // to point to the local backend API by passing the `MC_API_URL` env does not
65
- // work anymore). To make it work again, we can override the `env.json` config
66
- // with the env variable before injecting the values into the index.html.
67
- // NOTE: this is only necessary for development.
68
- process.env.MC_API_URL ? {
69
- mcApiUrl: process.env.MC_API_URL
70
- } : {}); // Resolve the placeholders of the `index.html` (template) file, before serving it.
71
-
72
-
73
- var html = mcHtmlTemplate.replaceHtmlPlaceholders(rawHtml, {
74
- env: enhancedLocalEnv,
75
- headers: compiledHeaders
76
- });
77
- return html;
78
- }
79
- };
80
- };
81
-
82
- function run() {
83
- return _run.apply(this, arguments);
84
- }
85
-
86
- function _run() {
87
- _run = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee() {
88
- var DEFAULT_PORT, applicationConfig$1, appEntryPoint, html, server;
89
- return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
90
- while (1) {
91
- switch (_context.prev = _context.next) {
92
- case 0:
93
- DEFAULT_PORT = _parseInt__default["default"](String(process.env.HTTP_PORT), 10) || 3001; // Load the Custom Application config file first.
94
-
95
- applicationConfig$1 = applicationConfig.processConfig(); // Ensure the `/public` folder exists.
96
-
97
- fs__default["default"].mkdirSync(paths.paths.appBuild, {
98
- recursive: true
99
- }); // Generate `index.html` (template).
100
-
101
- appEntryPoint = path__default["default"].relative(paths.paths.appRoot, paths.paths.entryPoint);
102
- html = mcHtmlTemplate.generateTemplate({
103
- // Define the module entry point (path relative to the `/public` folder).
104
- // NOTE: that this is different from the production configuration.
105
- scriptImports: ["<script type=\"module\" src=\"/../".concat(appEntryPoint, "\"></script>")]
106
- }); // Write `index.html` (template) into the `/public` folder.
107
-
108
- fs__default["default"].writeFileSync(paths.paths.appIndexHtml, html, {
109
- encoding: 'utf8'
110
- });
111
- _context.next = 8;
112
- return vite.createServer({
113
- root: paths.paths.appRoot,
114
- define: {
115
- 'process.env.DEBUG': _JSON$stringify__default["default"](false),
116
- 'process.env.NODE_ENV': _JSON$stringify__default["default"]('development')
117
- },
118
- server: {
119
- port: DEFAULT_PORT
120
- },
121
- plugins: [pluginGraphql__default["default"](), pluginReact__default["default"](), vitePluginSvgr.vitePluginSvgr(), vitePluginCustomApplication(applicationConfig$1)]
122
- });
123
-
124
- case 8:
125
- server = _context.sent;
126
- _context.next = 11;
127
- return server.listen();
128
-
129
- case 11:
130
- // Copy public assets to `/public` folder (even in development).
131
- fs__default["default"].copySync(path__default["default"].join(assets.packageLocation, 'html-page'), paths.paths.appBuild, {
132
- dereference: true
133
- });
134
- server.printUrls();
135
-
136
- case 13:
137
- case "end":
138
- return _context.stop();
139
- }
140
- }
141
- }, _callee);
142
- }));
143
- return _run.apply(this, arguments);
144
- }
145
-
146
- exports["default"] = run;
@@ -1,110 +0,0 @@
1
- 'use strict';
2
-
3
- var _asyncToGenerator = require('@babel/runtime-corejs3/helpers/asyncToGenerator');
4
- var _regeneratorRuntime = require('@babel/runtime-corejs3/regenerator');
5
- var fs = require('fs');
6
- var vite = require('vite');
7
- var pluginutils = require('@rollup/pluginutils');
8
-
9
- function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
10
-
11
- function _interopNamespace(e) {
12
- if (e && e.__esModule) return e;
13
- var n = Object.create(null);
14
- if (e) {
15
- Object.keys(e).forEach(function (k) {
16
- if (k !== 'default') {
17
- var d = Object.getOwnPropertyDescriptor(e, k);
18
- Object.defineProperty(n, k, d.get ? d : {
19
- enumerable: true,
20
- get: function () { return e[k]; }
21
- });
22
- }
23
- });
24
- }
25
- n["default"] = e;
26
- return Object.freeze(n);
27
- }
28
-
29
- var _regeneratorRuntime__default = /*#__PURE__*/_interopDefault(_regeneratorRuntime);
30
- var fs__default = /*#__PURE__*/_interopDefault(fs);
31
-
32
- function vitePluginSvgr() {
33
- var filter = pluginutils.createFilter('**/*.react.svg');
34
- return {
35
- name: 'vite-plugin-svgr',
36
- transform: function transform(_code, id) {
37
- return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee() {
38
- var _yield$import, transform, svgCode, componentCode, res;
39
-
40
- return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
41
- while (1) {
42
- switch (_context.prev = _context.next) {
43
- case 0:
44
- if (!filter(id)) {
45
- _context.next = 15;
46
- break;
47
- }
48
-
49
- _context.next = 3;
50
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('@svgr/core')); });
51
-
52
- case 3:
53
- _yield$import = _context.sent;
54
- transform = _yield$import.transform;
55
- _context.next = 7;
56
- return fs__default["default"].promises.readFile(id, 'utf8');
57
-
58
- case 7:
59
- svgCode = _context.sent;
60
- _context.next = 10;
61
- return transform(svgCode, {
62
- icon: false,
63
- svgoConfig: {
64
- plugins: [{
65
- // https://github.com/svg/svgo#default-preset
66
- name: 'preset-default',
67
- params: {
68
- overrides: {
69
- removeViewBox: false
70
- }
71
- }
72
- }]
73
- }
74
- }, {
75
- filePath: id,
76
- caller: {
77
- previousExport: null
78
- }
79
- });
80
-
81
- case 10:
82
- componentCode = _context.sent;
83
- _context.next = 13;
84
- return vite.transformWithEsbuild(componentCode, id, {
85
- loader: 'jsx'
86
- });
87
-
88
- case 13:
89
- res = _context.sent;
90
- return _context.abrupt("return", {
91
- code: res.code,
92
- map: null // TODO:
93
-
94
- });
95
-
96
- case 15:
97
- return _context.abrupt("return", null);
98
-
99
- case 16:
100
- case "end":
101
- return _context.stop();
102
- }
103
- }
104
- }, _callee);
105
- }))();
106
- }
107
- };
108
- }
109
-
110
- exports.vitePluginSvgr = vitePluginSvgr;
@@ -1,85 +0,0 @@
1
- import _asyncToGenerator from '@babel/runtime-corejs3/helpers/esm/asyncToGenerator';
2
- import _regeneratorRuntime from '@babel/runtime-corejs3/regenerator';
3
- import fs from 'fs';
4
- import { transformWithEsbuild } from 'vite';
5
- import { createFilter } from '@rollup/pluginutils';
6
-
7
- function vitePluginSvgr() {
8
- var filter = createFilter('**/*.react.svg');
9
- return {
10
- name: 'vite-plugin-svgr',
11
- transform: function transform(_code, id) {
12
- return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
13
- var _yield$import, transform, svgCode, componentCode, res;
14
-
15
- return _regeneratorRuntime.wrap(function _callee$(_context) {
16
- while (1) {
17
- switch (_context.prev = _context.next) {
18
- case 0:
19
- if (!filter(id)) {
20
- _context.next = 15;
21
- break;
22
- }
23
-
24
- _context.next = 3;
25
- return import('@svgr/core');
26
-
27
- case 3:
28
- _yield$import = _context.sent;
29
- transform = _yield$import.transform;
30
- _context.next = 7;
31
- return fs.promises.readFile(id, 'utf8');
32
-
33
- case 7:
34
- svgCode = _context.sent;
35
- _context.next = 10;
36
- return transform(svgCode, {
37
- icon: false,
38
- svgoConfig: {
39
- plugins: [{
40
- // https://github.com/svg/svgo#default-preset
41
- name: 'preset-default',
42
- params: {
43
- overrides: {
44
- removeViewBox: false
45
- }
46
- }
47
- }]
48
- }
49
- }, {
50
- filePath: id,
51
- caller: {
52
- previousExport: null
53
- }
54
- });
55
-
56
- case 10:
57
- componentCode = _context.sent;
58
- _context.next = 13;
59
- return transformWithEsbuild(componentCode, id, {
60
- loader: 'jsx'
61
- });
62
-
63
- case 13:
64
- res = _context.sent;
65
- return _context.abrupt("return", {
66
- code: res.code,
67
- map: null // TODO:
68
-
69
- });
70
-
71
- case 15:
72
- return _context.abrupt("return", null);
73
-
74
- case 16:
75
- case "end":
76
- return _context.stop();
77
- }
78
- }
79
- }, _callee);
80
- }))();
81
- }
82
- };
83
- }
84
-
85
- export { vitePluginSvgr as v };