@commercetools-frontend/mc-scripts 0.0.0-CRAFT-1791-20251006162610
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/LICENSE +21 -0
- package/README.md +7 -0
- package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.d.ts +2 -0
- package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.dev.js +7 -0
- package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.js +7 -0
- package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.prod.js +7 -0
- package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.esm.js +5 -0
- package/application-runtime/package.json +4 -0
- package/bin/cli.js +8 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.d.ts +2 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.dev.js +199 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.js +7 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.prod.js +199 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.esm.js +184 -0
- package/cli/package.json +4 -0
- package/config/create-webpack-config-for-development.js +8 -0
- package/config/create-webpack-config-for-production.js +8 -0
- package/config/vendors-to-transpile.js +6 -0
- package/dist/build-2a0a18bd.esm.js +155 -0
- package/dist/build-521f3f9f.cjs.prod.js +169 -0
- package/dist/build-988fc0f7.cjs.dev.js +169 -0
- package/dist/build-vite-16b1a575.cjs.dev.js +238 -0
- package/dist/build-vite-59e1f185.esm.js +208 -0
- package/dist/build-vite-5d317720.cjs.prod.js +238 -0
- package/dist/commercetools-frontend-mc-scripts.cjs.d.ts +2 -0
- package/dist/commercetools-frontend-mc-scripts.cjs.dev.js +29 -0
- package/dist/commercetools-frontend-mc-scripts.cjs.js +7 -0
- package/dist/commercetools-frontend-mc-scripts.cjs.prod.js +29 -0
- package/dist/commercetools-frontend-mc-scripts.esm.js +21 -0
- package/dist/compile-html-025cd493.esm.js +34 -0
- package/dist/compile-html-50fd05ec.cjs.prod.js +42 -0
- package/dist/compile-html-f4ac88cc.cjs.dev.js +42 -0
- package/dist/config-sync-70a16916.cjs.dev.js +852 -0
- package/dist/config-sync-72c20d80.cjs.prod.js +846 -0
- package/dist/config-sync-bc895390.esm.js +830 -0
- package/dist/create-postcss-config-cb7be312.cjs.dev.js +81 -0
- package/dist/create-postcss-config-dde0ccf1.esm.js +75 -0
- package/dist/create-postcss-config-edca0c33.cjs.prod.js +81 -0
- package/dist/create-webpack-config-for-development-1aed1cc0.cjs.prod.js +465 -0
- package/dist/create-webpack-config-for-development-a95f3634.esm.js +440 -0
- package/dist/create-webpack-config-for-development-d003697b.cjs.dev.js +465 -0
- package/dist/create-webpack-config-for-production-15fbe7db.cjs.dev.js +523 -0
- package/dist/create-webpack-config-for-production-764c482f.cjs.prod.js +523 -0
- package/dist/create-webpack-config-for-production-9f42c336.esm.js +493 -0
- package/dist/credentials-storage-66c1e51f.cjs.prod.js +95 -0
- package/dist/credentials-storage-d001f726.esm.js +83 -0
- package/dist/credentials-storage-e7884d17.cjs.dev.js +95 -0
- package/dist/declarations/src/application-runtime.d.ts +1 -0
- package/dist/declarations/src/cli.d.ts +4 -0
- package/dist/declarations/src/config/create-postcss-config.d.ts +4 -0
- package/dist/declarations/src/config/create-webpack-config-for-development.d.ts +10 -0
- package/dist/declarations/src/config/create-webpack-config-for-production.d.ts +10 -0
- package/dist/declarations/src/config/vendors-to-transpile.d.ts +2 -0
- package/dist/declarations/src/deprecated-entry-points.d.ts +7 -0
- package/dist/declarations/src/index.d.ts +3 -0
- package/dist/declarations/src/postcss.d.ts +1 -0
- package/dist/declarations/src/types.d.ts +94 -0
- package/dist/declarations/src/version.d.ts +2 -0
- package/dist/declarations/src/webpack-loaders/i18n-message-compilation-loader.d.ts +3 -0
- package/dist/declarations/src/webpack.d.ts +2 -0
- package/dist/deployment-previews-set-17e8ed48.cjs.prod.js +202 -0
- package/dist/deployment-previews-set-3648972f.esm.js +191 -0
- package/dist/deployment-previews-set-37aef990.cjs.dev.js +202 -0
- package/dist/does-file-exist-32618334.esm.js +12 -0
- package/dist/does-file-exist-be53305d.cjs.prod.js +18 -0
- package/dist/does-file-exist-eb86baca.cjs.dev.js +18 -0
- package/dist/graphql-requests-6a47ad5b.esm.js +247 -0
- package/dist/graphql-requests-779b867b.cjs.dev.js +270 -0
- package/dist/graphql-requests-8086eba7.cjs.prod.js +270 -0
- package/dist/has-jsx-runtime-aa5d21ee.cjs.dev.js +15 -0
- package/dist/has-jsx-runtime-c3202df5.cjs.prod.js +15 -0
- package/dist/has-jsx-runtime-e3ecb09b.esm.js +13 -0
- package/dist/i18n-message-complilation-21d3b0aa.esm.js +15 -0
- package/dist/i18n-message-complilation-7311cb29.cjs.dev.js +23 -0
- package/dist/i18n-message-complilation-7762da61.cjs.prod.js +23 -0
- package/dist/login-0a728449.esm.js +229 -0
- package/dist/login-817a5a26.cjs.dev.js +270 -0
- package/dist/login-85c25393.cjs.prod.js +270 -0
- package/dist/optimizations-7789145e.cjs.dev.js +85 -0
- package/dist/optimizations-bf991634.esm.js +67 -0
- package/dist/optimizations-fb93514f.cjs.prod.js +85 -0
- package/dist/package-7e170dc4.cjs.dev.js +160 -0
- package/dist/package-940b0a2a.cjs.prod.js +160 -0
- package/dist/package-99e547a7.esm.js +158 -0
- package/dist/paths-39f22b8b.esm.js +36 -0
- package/dist/paths-7768b440.cjs.prod.js +44 -0
- package/dist/paths-b76fc753.cjs.dev.js +44 -0
- package/dist/serve-1036c2de.esm.js +55 -0
- package/dist/serve-50d33f0b.cjs.dev.js +64 -0
- package/dist/serve-8a506da6.cjs.prod.js +64 -0
- package/dist/start-1d677ad8.cjs.dev.js +177 -0
- package/dist/start-2a7ae03d.esm.js +164 -0
- package/dist/start-f56cb5f7.cjs.prod.js +177 -0
- package/dist/start-vite-068e9f73.cjs.dev.js +128 -0
- package/dist/start-vite-29078b3a.cjs.prod.js +128 -0
- package/dist/start-vite-7d1161e8.esm.js +116 -0
- package/dist/vendors-to-transpile-04a49d40.cjs.prod.js +5 -0
- package/dist/vendors-to-transpile-6ab4ea06.cjs.dev.js +5 -0
- package/dist/vendors-to-transpile-7dc84a72.esm.js +3 -0
- package/dist/vite-plugin-svgr-4034a834.cjs.prod.js +151 -0
- package/dist/vite-plugin-svgr-7d06f400.cjs.dev.js +151 -0
- package/dist/vite-plugin-svgr-de6ee7da.esm.js +125 -0
- package/package.json +156 -0
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.d.ts +2 -0
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.dev.js +12 -0
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.js +7 -0
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.prod.js +12 -0
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.esm.js +4 -0
- package/postcss/package.json +4 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.d.ts +2 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.dev.js +57 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.js +7 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.prod.js +57 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.esm.js +48 -0
- package/webpack/package.json +4 -0
- package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.cjs.d.ts +3 -0
- package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.cjs.dev.js +30 -0
- package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.cjs.js +7 -0
- package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.cjs.prod.js +30 -0
- package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.esm.js +26 -0
- package/webpack-loaders/i18n-message-compilation-loader/package.json +4 -0
|
@@ -0,0 +1,523 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
|
|
4
|
+
var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
|
|
5
|
+
var _Object$getOwnPropertyDescriptor = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
|
|
6
|
+
var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
|
|
7
|
+
var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
|
|
8
|
+
var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
|
|
9
|
+
var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
|
|
10
|
+
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
11
|
+
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
|
12
|
+
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
13
|
+
var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
|
|
14
|
+
var _endsWithInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/ends-with');
|
|
15
|
+
var _Number$isInteger = require('@babel/runtime-corejs3/core-js-stable/number/is-integer');
|
|
16
|
+
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
17
|
+
var crypto = require('crypto');
|
|
18
|
+
var CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
|
|
19
|
+
var HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
20
|
+
var MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
21
|
+
var MomentLocalesPlugin = require('moment-locales-webpack-plugin');
|
|
22
|
+
var TerserPlugin = require('terser-webpack-plugin');
|
|
23
|
+
var webpack = require('webpack');
|
|
24
|
+
var webpackBundleAnalyzer = require('webpack-bundle-analyzer');
|
|
25
|
+
var _classCallCheck = require('@babel/runtime-corejs3/helpers/classCallCheck');
|
|
26
|
+
var _createClass = require('@babel/runtime-corejs3/helpers/createClass');
|
|
27
|
+
var _bindInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/bind');
|
|
28
|
+
var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
|
|
29
|
+
var _Object$assign = require('@babel/runtime-corejs3/core-js-stable/object/assign');
|
|
30
|
+
var fs = require('fs');
|
|
31
|
+
var path = require('path');
|
|
32
|
+
var createPostcssConfig = require('./create-postcss-config-cb7be312.cjs.dev.js');
|
|
33
|
+
var hasJsxRuntime = require('./has-jsx-runtime-aa5d21ee.cjs.dev.js');
|
|
34
|
+
var optimizations = require('./optimizations-7789145e.cjs.dev.js');
|
|
35
|
+
var paths = require('./paths-b76fc753.cjs.dev.js');
|
|
36
|
+
var vendorsToTranspile = require('./vendors-to-transpile-6ab4ea06.cjs.dev.js');
|
|
37
|
+
|
|
38
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
39
|
+
|
|
40
|
+
var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
|
|
41
|
+
var _Object$getOwnPropertySymbols__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertySymbols);
|
|
42
|
+
var _Object$getOwnPropertyDescriptor__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptor);
|
|
43
|
+
var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachInstanceProperty);
|
|
44
|
+
var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
|
|
45
|
+
var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
|
|
46
|
+
var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
|
|
47
|
+
var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
|
|
48
|
+
var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
|
|
49
|
+
var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
|
|
50
|
+
var _endsWithInstanceProperty__default = /*#__PURE__*/_interopDefault(_endsWithInstanceProperty);
|
|
51
|
+
var _Number$isInteger__default = /*#__PURE__*/_interopDefault(_Number$isInteger);
|
|
52
|
+
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
53
|
+
var crypto__default = /*#__PURE__*/_interopDefault(crypto);
|
|
54
|
+
var CssMinimizerPlugin__default = /*#__PURE__*/_interopDefault(CssMinimizerPlugin);
|
|
55
|
+
var HtmlWebpackPlugin__default = /*#__PURE__*/_interopDefault(HtmlWebpackPlugin);
|
|
56
|
+
var MiniCssExtractPlugin__default = /*#__PURE__*/_interopDefault(MiniCssExtractPlugin);
|
|
57
|
+
var MomentLocalesPlugin__default = /*#__PURE__*/_interopDefault(MomentLocalesPlugin);
|
|
58
|
+
var TerserPlugin__default = /*#__PURE__*/_interopDefault(TerserPlugin);
|
|
59
|
+
var webpack__default = /*#__PURE__*/_interopDefault(webpack);
|
|
60
|
+
var _bindInstanceProperty__default = /*#__PURE__*/_interopDefault(_bindInstanceProperty);
|
|
61
|
+
var _reduceInstanceProperty__default = /*#__PURE__*/_interopDefault(_reduceInstanceProperty);
|
|
62
|
+
var _Object$assign__default = /*#__PURE__*/_interopDefault(_Object$assign);
|
|
63
|
+
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
64
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
65
|
+
|
|
66
|
+
let FinalStatsWriterPlugin = /*#__PURE__*/function () {
|
|
67
|
+
// Expected options:
|
|
68
|
+
// - `outputPath`
|
|
69
|
+
// - `includeFields`
|
|
70
|
+
function FinalStatsWriterPlugin(config) {
|
|
71
|
+
_classCallCheck(this, FinalStatsWriterPlugin);
|
|
72
|
+
this.config = void 0;
|
|
73
|
+
if (!config) throw new Error('Missing config options');
|
|
74
|
+
this.config = config;
|
|
75
|
+
}
|
|
76
|
+
return _createClass(FinalStatsWriterPlugin, [{
|
|
77
|
+
key: "apply",
|
|
78
|
+
value: function apply(compiler) {
|
|
79
|
+
// This is the only hook that return the `stats` plugin
|
|
80
|
+
// with the `time` info. It also contains all the stats that
|
|
81
|
+
// we would get from the original `emit` hook.
|
|
82
|
+
// https://webpack.js.org/api/compiler-hooks/#done
|
|
83
|
+
// https://webpack.js.org/api/plugins/#plugin-types
|
|
84
|
+
if (compiler.hooks) {
|
|
85
|
+
var _context;
|
|
86
|
+
compiler.hooks.done.tap('custom-stats-writer-plugin', _bindInstanceProperty__default["default"](_context = this.writeStats).call(_context, this));
|
|
87
|
+
} else {
|
|
88
|
+
var _context2;
|
|
89
|
+
// @ts-ignore
|
|
90
|
+
compiler.plugin('done', _bindInstanceProperty__default["default"](_context2 = this.writeStats).call(_context2, this));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}, {
|
|
94
|
+
key: "writeStats",
|
|
95
|
+
value: function writeStats(stats) {
|
|
96
|
+
let finalStats = stats.toJson();
|
|
97
|
+
|
|
98
|
+
// Filter only included fields
|
|
99
|
+
if (this.config.includeFields) {
|
|
100
|
+
var _context3;
|
|
101
|
+
finalStats = _reduceInstanceProperty__default["default"](_context3 = this.config.includeFields).call(_context3, (aggregatedStats, key) =>
|
|
102
|
+
// eslint-disable-next-line
|
|
103
|
+
_Object$assign__default["default"]({}, aggregatedStats, {
|
|
104
|
+
[key]: finalStats[key]
|
|
105
|
+
}), {});
|
|
106
|
+
}
|
|
107
|
+
try {
|
|
108
|
+
fs__default["default"].accessSync(this.config.outputPath, fs__default["default"].constants.F_OK);
|
|
109
|
+
fs__default["default"].writeFileSync(path__default["default"].join(this.config.outputPath, 'stats.json'), _JSON$stringify__default["default"](finalStats, null, 2));
|
|
110
|
+
} catch (error) {
|
|
111
|
+
// eslint-disable-next-line no-console
|
|
112
|
+
console.warn(`[FinalStatsWriterPlugin] The dist folder could not be found at ${this.config.outputPath}. Check the console for errors during the webpack compilation.`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}]);
|
|
116
|
+
}();
|
|
117
|
+
|
|
118
|
+
function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
119
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context7, _context8; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context7 = ownKeys(Object(t), !0)).call(_context7, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context8 = ownKeys(Object(t))).call(_context8, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
120
|
+
// https://babeljs.io/blog/2017/09/11/zero-config-with-babel-macros
|
|
121
|
+
const momentLocalesToKeep = ["de", "de-at", "de-ch", "en-au", "en-ca", "en-gb", "en-ie", "en-in", "en-nz", "en-sg", "es", "es-do", "es-mx", "fr", "pt-br"];
|
|
122
|
+
const defaultToggleFlags = {
|
|
123
|
+
// Allow to disable CSS extraction in case it's not necessary (e.g. for Storybook)
|
|
124
|
+
enableExtractCss: true,
|
|
125
|
+
// Allow to disable index.html generation in case it's not necessary (e.g. for Storybook)
|
|
126
|
+
generateIndexHtml: true,
|
|
127
|
+
// Some plugins spawn workers to speed up the build. However this can cause trouble on
|
|
128
|
+
// certain machines local and CI. This flag set to limit or disable any parallelism.
|
|
129
|
+
// Options:
|
|
130
|
+
// `true` to default to the machines number of CPUs
|
|
131
|
+
// `false` to disable any paralelism
|
|
132
|
+
// `int` for a specific number of CPUs
|
|
133
|
+
parallelism: true,
|
|
134
|
+
// Some environemnts do not require `core-js` and can hence disable
|
|
135
|
+
// it explicitely. This will disable `core-js` for `preset-env` and the
|
|
136
|
+
// `plugin-transform-runtime`.
|
|
137
|
+
disableCoreJs: false,
|
|
138
|
+
// Pre-parse default `formatjs` messages into AST
|
|
139
|
+
i18nAst: false,
|
|
140
|
+
// Remove default `formatjs` messages from bundles.
|
|
141
|
+
i18nRemoveDefaultMessage: false
|
|
142
|
+
};
|
|
143
|
+
const defaultOptions = {
|
|
144
|
+
entryPoint: paths.paths.entryPoint,
|
|
145
|
+
sourceFolders: paths.paths.sourceFolders,
|
|
146
|
+
postcssOptions: {},
|
|
147
|
+
toggleFlags: defaultToggleFlags
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* This is a factory function to create the default webpack config
|
|
152
|
+
* for a MC Application in `production` mode.
|
|
153
|
+
* The function requires the file path to the related application
|
|
154
|
+
* "entry point".
|
|
155
|
+
*/
|
|
156
|
+
function createWebpackConfigForProduction() {
|
|
157
|
+
var _context, _context2, _context3, _context4, _context5, _context6;
|
|
158
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
159
|
+
const mergedOptions = _objectSpread(_objectSpread(_objectSpread({}, defaultOptions), options), {}, {
|
|
160
|
+
toggleFlags: _objectSpread(_objectSpread({}, defaultToggleFlags), options.toggleFlags)
|
|
161
|
+
});
|
|
162
|
+
const appDependencies = require(paths.paths.appPackageJson).dependencies;
|
|
163
|
+
return {
|
|
164
|
+
// Don't attempt to continue if there are any errors.
|
|
165
|
+
bail: true,
|
|
166
|
+
// https://webpack.js.org/concepts/#mode
|
|
167
|
+
mode: 'production',
|
|
168
|
+
// We generate sourcemaps in production. This is slow but gives good results.
|
|
169
|
+
// Sourcemaps are pushed to Google Storage and Sentry.
|
|
170
|
+
// https://webpack.js.org/configuration/devtool/#devtool
|
|
171
|
+
devtool: 'source-map',
|
|
172
|
+
// https://medium.com/webpack/webpack-4-code-splitting-chunk-graph-and-the-splitchunks-optimization-be739a861366
|
|
173
|
+
// https://medium.com/webpack/webpack-4-mode-and-optimization-5423a6bc597a
|
|
174
|
+
optimization: {
|
|
175
|
+
minimizer: _filterInstanceProperty__default["default"](_context = [new TerserPlugin__default["default"]({
|
|
176
|
+
terserOptions: {
|
|
177
|
+
parse: {
|
|
178
|
+
// we want terser to parse ecma 8 code. However, we don't want it
|
|
179
|
+
// to apply any minification steps that turns valid ecma 5 code
|
|
180
|
+
// into invalid ecma 5 code. This is why the 'compress' and 'output'
|
|
181
|
+
// sections only apply transformations that are ecma 5 safe
|
|
182
|
+
// https://github.com/facebook/create-react-app/pull/4234
|
|
183
|
+
ecma: 2018
|
|
184
|
+
},
|
|
185
|
+
compress: {
|
|
186
|
+
ecma: 5,
|
|
187
|
+
// Disabled because of an issue with Uglify breaking seemingly valid code:
|
|
188
|
+
// https://github.com/facebook/create-react-app/issues/2376
|
|
189
|
+
// Pending further investigation:
|
|
190
|
+
// https://github.com/mishoo/UglifyJS2/issues/2011
|
|
191
|
+
comparisons: false,
|
|
192
|
+
// Disabled because of an issue with Terser breaking valid code:
|
|
193
|
+
// https://github.com/facebook/create-react-app/issues/5250
|
|
194
|
+
// Pending futher investigation:
|
|
195
|
+
// https://github.com/terser-js/terser/issues/120
|
|
196
|
+
inline: 2
|
|
197
|
+
},
|
|
198
|
+
mangle: {
|
|
199
|
+
safari10: true
|
|
200
|
+
},
|
|
201
|
+
// Added for profiling in devtools
|
|
202
|
+
keep_classnames: true,
|
|
203
|
+
keep_fnames: true,
|
|
204
|
+
output: {
|
|
205
|
+
ecma: 5,
|
|
206
|
+
comments: false,
|
|
207
|
+
// Turned on because emoji and regex is not minified properly using default
|
|
208
|
+
// https://github.com/facebook/create-react-app/issues/2488
|
|
209
|
+
ascii_only: true
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
// Use multi-process parallel running to improve the build speed
|
|
213
|
+
// Default number of concurrent runs: os.cpus().length - 1
|
|
214
|
+
parallel: mergedOptions.toggleFlags.parallelism
|
|
215
|
+
}), mergedOptions.toggleFlags.enableExtractCss && new CssMinimizerPlugin__default["default"]()]).call(_context, Boolean),
|
|
216
|
+
// Keep the runtime chunk separated to enable long term caching
|
|
217
|
+
runtimeChunk: {
|
|
218
|
+
name: 'runtime'
|
|
219
|
+
},
|
|
220
|
+
splitChunks: {
|
|
221
|
+
cacheGroups: optimizations.getWepbackCacheGroups(appDependencies)
|
|
222
|
+
},
|
|
223
|
+
moduleIds: 'named',
|
|
224
|
+
chunkIds: 'deterministic'
|
|
225
|
+
},
|
|
226
|
+
resolve: {
|
|
227
|
+
// These are the reasonable defaults supported by the Node ecosystem.
|
|
228
|
+
// We also include JSX as a common component filename extension to support
|
|
229
|
+
// some tools, although we do not recommend using it, see:
|
|
230
|
+
// https://github.com/facebook/create-react-app/issues/290
|
|
231
|
+
// `web` extension prefixes have been added for better support
|
|
232
|
+
// for React Native Web.
|
|
233
|
+
extensions: _mapInstanceProperty__default["default"](_context2 = ['js', 'mjs', 'cjs', 'ts', 'tsx', 'json', 'jsx']).call(_context2, ext => `.${ext}`),
|
|
234
|
+
// NOTE: this is meant to be a temporary list of fallback/polyfills for certain
|
|
235
|
+
// nodejs modules. With Webpack <5 these polyfills were included by default in Webpack,
|
|
236
|
+
// however now it's not the case anymore.
|
|
237
|
+
// See also related work in CRA: https://github.com/facebook/create-react-app/pull/11764
|
|
238
|
+
fallback: {
|
|
239
|
+
querystring: require.resolve('querystring-es3')
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
// In production, we only want to load the polyfills and the app code.
|
|
243
|
+
entry: {
|
|
244
|
+
app: _filterInstanceProperty__default["default"](_context3 = [require.resolve('@commercetools-frontend/mc-scripts/application-runtime'), !mergedOptions.toggleFlags.disableCoreJs && require.resolve('core-js/stable'), mergedOptions.entryPoint]).call(_context3, Boolean)
|
|
245
|
+
},
|
|
246
|
+
output: {
|
|
247
|
+
// Generated JS file names (with nested folders).
|
|
248
|
+
// There will be one main bundle, and one file per asynchronous chunk.
|
|
249
|
+
filename: '[name].[chunkhash].js',
|
|
250
|
+
chunkFilename: '[id].[name].[chunkhash].js',
|
|
251
|
+
// The build folder.
|
|
252
|
+
path: paths.paths.appBuild,
|
|
253
|
+
pathinfo: false,
|
|
254
|
+
// Will be injected on runtime. See `packages/application-shell/src/public-path.js`
|
|
255
|
+
publicPath: ''
|
|
256
|
+
},
|
|
257
|
+
plugins: _filterInstanceProperty__default["default"](_context4 = [
|
|
258
|
+
// Allows to "assign" custom options to the `webpack` object.
|
|
259
|
+
// At the moment, this is used to share some props with `postcss.config`.
|
|
260
|
+
new webpack__default["default"].LoaderOptionsPlugin({
|
|
261
|
+
options: {
|
|
262
|
+
sourceFolders: mergedOptions.sourceFolders,
|
|
263
|
+
context: __dirname
|
|
264
|
+
}
|
|
265
|
+
}),
|
|
266
|
+
// Makes some environment variables available to the JS code, for example:
|
|
267
|
+
// if (process.env.NODE_ENV === 'production') { ... }.
|
|
268
|
+
new webpack__default["default"].DefinePlugin({
|
|
269
|
+
__DEV__: 'false',
|
|
270
|
+
'process.env': {
|
|
271
|
+
NODE_ENV: _JSON$stringify__default["default"]('production')
|
|
272
|
+
}
|
|
273
|
+
}),
|
|
274
|
+
// Only keep locales that are available in the Merchant Center.
|
|
275
|
+
new MomentLocalesPlugin__default["default"]({
|
|
276
|
+
localesToKeep: momentLocalesToKeep
|
|
277
|
+
}),
|
|
278
|
+
// Generate a `stats.json` file containing information and paths to
|
|
279
|
+
// the assets that webpack created.
|
|
280
|
+
// This is necessary to programmatically refer to the correct bundle path
|
|
281
|
+
// in the `index.html`.
|
|
282
|
+
new FinalStatsWriterPlugin({
|
|
283
|
+
outputPath: paths.paths.appBuild,
|
|
284
|
+
includeFields: ['entrypoints', 'assets', 'publicPath', 'time']
|
|
285
|
+
}), mergedOptions.toggleFlags.generateIndexHtml && new HtmlWebpackPlugin__default["default"]({
|
|
286
|
+
inject: false,
|
|
287
|
+
filename: 'index.html.template',
|
|
288
|
+
template: require.resolve('@commercetools-frontend/mc-html-template/webpack')
|
|
289
|
+
}), mergedOptions.toggleFlags.enableExtractCss &&
|
|
290
|
+
// Extracts CSS into one CSS file to mimic CSS order in dev
|
|
291
|
+
new MiniCssExtractPlugin__default["default"]({
|
|
292
|
+
filename: '[name].[chunkhash].css',
|
|
293
|
+
chunkFilename: '[id].[name].[chunkhash].css'
|
|
294
|
+
}), process.env.ANALYZE_BUNDLE === 'true' && new webpackBundleAnalyzer.BundleAnalyzerPlugin({
|
|
295
|
+
defaultSizes: 'gzip'
|
|
296
|
+
})]).call(_context4, Boolean),
|
|
297
|
+
module: {
|
|
298
|
+
// Makes missing exports an error instead of warning.
|
|
299
|
+
strictExportPresence: true,
|
|
300
|
+
rules: _filterInstanceProperty__default["default"](_context5 = [
|
|
301
|
+
// For svg icons, we want to get them transformed into React components
|
|
302
|
+
// when we import them.
|
|
303
|
+
{
|
|
304
|
+
test: /\.react\.svg$/,
|
|
305
|
+
use: [{
|
|
306
|
+
loader: require.resolve('babel-loader'),
|
|
307
|
+
options: {
|
|
308
|
+
babelrc: false,
|
|
309
|
+
presets: [[require.resolve('@commercetools-frontend/babel-preset-mc-app'), {
|
|
310
|
+
runtime: hasJsxRuntime.hasJsxRuntime() ? 'automatic' : 'classic',
|
|
311
|
+
disableCoreJs: mergedOptions.toggleFlags.disableCoreJs,
|
|
312
|
+
i18nAst: mergedOptions.toggleFlags.i18nAst,
|
|
313
|
+
i18nRemoveDefaultMessage: mergedOptions.toggleFlags.i18nRemoveDefaultMessage
|
|
314
|
+
}]],
|
|
315
|
+
// This is a feature of `babel-loader` for webpack (not Babel itself).
|
|
316
|
+
// It enables caching results in ./node_modules/.cache/babel-loader/
|
|
317
|
+
// directory for faster rebuilds.
|
|
318
|
+
cacheDirectory: true,
|
|
319
|
+
highlightCode: true
|
|
320
|
+
}
|
|
321
|
+
}, {
|
|
322
|
+
loader: require.resolve('@svgr/webpack'),
|
|
323
|
+
options: {
|
|
324
|
+
icon: false,
|
|
325
|
+
svgoConfig: {
|
|
326
|
+
plugins: [{
|
|
327
|
+
// https://github.com/svg/svgo#default-preset
|
|
328
|
+
name: 'preset-default',
|
|
329
|
+
params: {
|
|
330
|
+
overrides: {
|
|
331
|
+
removeViewBox: false
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
},
|
|
335
|
+
// Avoid collisions with ids in other SVGs,
|
|
336
|
+
// which was causing incorrect masking, gradient directions, etc
|
|
337
|
+
// this is an ongoing issue with both SVGR and SVGO,
|
|
338
|
+
// https://github.com/svg/svgo/issues/913#issuecomment-369373572
|
|
339
|
+
// see SVGR issues:
|
|
340
|
+
// https://github.com/gregberge/svgr/issues/322
|
|
341
|
+
// https://github.com/gregberge/svgr/issues/210
|
|
342
|
+
// see SVGO issues:
|
|
343
|
+
// https://github.com/svg/svgo/issues/674
|
|
344
|
+
// https://github.com/svg/svgo/issues/1746
|
|
345
|
+
//
|
|
346
|
+
// Initially, a naive counter was implemented based on this github comment:
|
|
347
|
+
// https://github.com/svg/svgo/issues/1746#issuecomment-1803600573
|
|
348
|
+
// But while that implementation insured id’s that are unique,
|
|
349
|
+
// it did not work in cases where the id is both declared and referenced in the same file,
|
|
350
|
+
// because the refernce gets a separate unique ID (a different number from the counter).
|
|
351
|
+
//
|
|
352
|
+
// The current implementation is based on this github comment:
|
|
353
|
+
// https://github.com/svg/svgo/issues/913#issuecomment-369373572
|
|
354
|
+
// Generates a hash of the filepath of the svg file, resulting in a prefix which is:
|
|
355
|
+
// - Short,
|
|
356
|
+
// - With characters valid for IDs,
|
|
357
|
+
// - The same within a file,
|
|
358
|
+
// - And different in different files.
|
|
359
|
+
{
|
|
360
|
+
name: 'prefixIds',
|
|
361
|
+
params: {
|
|
362
|
+
delim: '',
|
|
363
|
+
prefix: (_, info) => `svg${crypto__default["default"].createHash('shake256', {
|
|
364
|
+
outputLength: 6
|
|
365
|
+
}).update(info.path || '').digest('hex')}`
|
|
366
|
+
}
|
|
367
|
+
}]
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}]
|
|
371
|
+
},
|
|
372
|
+
// For normal svg files (not icons) we should load the file normally
|
|
373
|
+
// and simply use it as a `<img src/>`.
|
|
374
|
+
{
|
|
375
|
+
test: function testForNormalSvgFiles(fileName) {
|
|
376
|
+
return (
|
|
377
|
+
// Use this only for plain SVG.
|
|
378
|
+
// For SVG as React components, see loader above.
|
|
379
|
+
_endsWithInstanceProperty__default["default"](fileName).call(fileName, '.svg') && !_endsWithInstanceProperty__default["default"](fileName).call(fileName, '.react.svg')
|
|
380
|
+
);
|
|
381
|
+
},
|
|
382
|
+
use: [{
|
|
383
|
+
loader: require.resolve('svg-url-loader')
|
|
384
|
+
}]
|
|
385
|
+
}, {
|
|
386
|
+
test: /\.png$/,
|
|
387
|
+
type: 'asset/resource'
|
|
388
|
+
},
|
|
389
|
+
// "postcss" loader applies autoprefixer to our CSS
|
|
390
|
+
// "css" loader resolves paths in CSS and adds assets as dependencies.
|
|
391
|
+
// "style" loader turns CSS into JS modules that inject <style> tags.
|
|
392
|
+
// In production, we use MiniCSSExtractPlugin to extract that CSS
|
|
393
|
+
// to a file, but in development "style" loader enables hot editing
|
|
394
|
+
// of CSS.
|
|
395
|
+
// By default we support CSS Modules with the extension `.mod.css` and `.module.css`.
|
|
396
|
+
{
|
|
397
|
+
test: /\.(mod|module)\.css$/,
|
|
398
|
+
include: mergedOptions.sourceFolders,
|
|
399
|
+
use: [mergedOptions.toggleFlags.enableExtractCss ? MiniCssExtractPlugin__default["default"].loader : require.resolve('style-loader'), {
|
|
400
|
+
loader: require.resolve('css-loader'),
|
|
401
|
+
options: {
|
|
402
|
+
modules: {
|
|
403
|
+
mode: 'local',
|
|
404
|
+
localIdentName: '[name]__[local]___[hash:base64:5]',
|
|
405
|
+
localIdentHashSalt: 'ct'
|
|
406
|
+
},
|
|
407
|
+
importLoaders: 1
|
|
408
|
+
}
|
|
409
|
+
}, {
|
|
410
|
+
loader: require.resolve('postcss-loader'),
|
|
411
|
+
options: {
|
|
412
|
+
postcssOptions: createPostcssConfig.createPostcssConfig(mergedOptions.postcssOptions)
|
|
413
|
+
}
|
|
414
|
+
}]
|
|
415
|
+
}, {
|
|
416
|
+
test: function testForNormalCssFiles(fileName) {
|
|
417
|
+
return (
|
|
418
|
+
// Use this only for plain CSS.
|
|
419
|
+
// For css-modules, see loader above.
|
|
420
|
+
_endsWithInstanceProperty__default["default"](fileName).call(fileName, '.css') && !(_endsWithInstanceProperty__default["default"](fileName).call(fileName, '.mod.css') || _endsWithInstanceProperty__default["default"](fileName).call(fileName, '.module.css'))
|
|
421
|
+
);
|
|
422
|
+
},
|
|
423
|
+
// "postcss" loader applies autoprefixer to our CSS.
|
|
424
|
+
// "css" loader resolves paths in CSS and adds assets as dependencies.
|
|
425
|
+
// "MiniCssExtractPlugin" or "style" loader extracts css to one file per css file.
|
|
426
|
+
oneOf: [{
|
|
427
|
+
// Use "postcss" for all the included source folders.
|
|
428
|
+
include: mergedOptions.sourceFolders,
|
|
429
|
+
use: [mergedOptions.toggleFlags.enableExtractCss ? MiniCssExtractPlugin__default["default"].loader : require.resolve('style-loader'), {
|
|
430
|
+
loader: require.resolve('css-loader'),
|
|
431
|
+
options: {
|
|
432
|
+
modules: {
|
|
433
|
+
mode: 'icss'
|
|
434
|
+
},
|
|
435
|
+
importLoaders: 1
|
|
436
|
+
}
|
|
437
|
+
}, {
|
|
438
|
+
loader: require.resolve('postcss-loader'),
|
|
439
|
+
options: {
|
|
440
|
+
postcssOptions: createPostcssConfig.createPostcssConfig(mergedOptions.postcssOptions)
|
|
441
|
+
}
|
|
442
|
+
}]
|
|
443
|
+
}, {
|
|
444
|
+
// For all other vendor CSS, do not use "postcss" loader.
|
|
445
|
+
// But still use MiniCssExtractPlugin :)
|
|
446
|
+
include: /node_modules/,
|
|
447
|
+
use: [mergedOptions.toggleFlags.enableExtractCss ? MiniCssExtractPlugin__default["default"].loader : require.resolve('style-loader'), {
|
|
448
|
+
loader: require.resolve('css-loader'),
|
|
449
|
+
options: {
|
|
450
|
+
modules: {
|
|
451
|
+
mode: 'icss'
|
|
452
|
+
},
|
|
453
|
+
importLoaders: 1
|
|
454
|
+
}
|
|
455
|
+
}],
|
|
456
|
+
// Don't consider CSS imports dead code even if the
|
|
457
|
+
// containing package claims to have no side effects.
|
|
458
|
+
// Remove this when webpack adds a warning or an error for this.
|
|
459
|
+
// See https://github.com/webpack/webpack/issues/6571
|
|
460
|
+
sideEffects: true
|
|
461
|
+
}]
|
|
462
|
+
},
|
|
463
|
+
// Fix for react-intl
|
|
464
|
+
// https://github.com/formatjs/formatjs/issues/143#issuecomment-518774786
|
|
465
|
+
{
|
|
466
|
+
test: /\.mjs$/,
|
|
467
|
+
type: 'javascript/auto',
|
|
468
|
+
resolve: {
|
|
469
|
+
// https://webpack.js.org/configuration/module/#resolvefullyspecified
|
|
470
|
+
fullySpecified: false
|
|
471
|
+
}
|
|
472
|
+
},
|
|
473
|
+
// Process application JavaScript with Babel.
|
|
474
|
+
{
|
|
475
|
+
test: /\.(js|mjs|cjs|jsx|ts|tsx)$/,
|
|
476
|
+
use: [
|
|
477
|
+
// This loader parallelizes code compilation, it is optional but
|
|
478
|
+
// improves compile time on larger projects
|
|
479
|
+
{
|
|
480
|
+
loader: require.resolve('thread-loader'),
|
|
481
|
+
options: _objectSpread({}, _Number$isInteger__default["default"](mergedOptions.toggleFlags.parallelism) ? {
|
|
482
|
+
workers: mergedOptions.toggleFlags.parallelism
|
|
483
|
+
} : {})
|
|
484
|
+
}, {
|
|
485
|
+
loader: require.resolve('babel-loader'),
|
|
486
|
+
options: {
|
|
487
|
+
babelrc: false,
|
|
488
|
+
configFile: false,
|
|
489
|
+
compact: false,
|
|
490
|
+
presets: [[require.resolve('@commercetools-frontend/babel-preset-mc-app'), {
|
|
491
|
+
runtime: hasJsxRuntime.hasJsxRuntime() ? 'automatic' : 'classic'
|
|
492
|
+
}]],
|
|
493
|
+
// This is a feature of `babel-loader` for webpack (not Babel itself).
|
|
494
|
+
// It enables caching results in ./node_modules/.cache/babel-loader/
|
|
495
|
+
// directory for faster rebuilds.
|
|
496
|
+
cacheDirectory: true,
|
|
497
|
+
highlightCode: true
|
|
498
|
+
}
|
|
499
|
+
}],
|
|
500
|
+
include: _concatInstanceProperty__default["default"](_context6 = mergedOptions.sourceFolders).call(_context6, vendorsToTranspile.vendorsToTranspile),
|
|
501
|
+
// Disable require.ensure as it's not a standard language feature.
|
|
502
|
+
parser: {
|
|
503
|
+
requireEnsure: false
|
|
504
|
+
}
|
|
505
|
+
},
|
|
506
|
+
// Allow to import `*.graphql` SDL files.
|
|
507
|
+
{
|
|
508
|
+
test: /\.graphql$/,
|
|
509
|
+
include: mergedOptions.sourceFolders,
|
|
510
|
+
exclude: /node_modules/,
|
|
511
|
+
use: [require.resolve('graphql-tag/loader')]
|
|
512
|
+
}, !(process.env.DISABLE_I18N_MESSAGE_COMPILATION === 'true') && {
|
|
513
|
+
test: /i18n\/data\/.*\.json$/,
|
|
514
|
+
use: [require.resolve('@commercetools-frontend/mc-scripts/webpack-loaders/i18n-message-compilation-loader')]
|
|
515
|
+
}]).call(_context5, Boolean)
|
|
516
|
+
},
|
|
517
|
+
// Turn off performance processing because we utilize
|
|
518
|
+
// our own hints via the FileSizeReporter
|
|
519
|
+
performance: false
|
|
520
|
+
};
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
exports.createWebpackConfigForProduction = createWebpackConfigForProduction;
|