@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,465 @@
|
|
|
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 _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
12
|
+
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
|
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 _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
16
|
+
var crypto = require('crypto');
|
|
17
|
+
var path = require('path');
|
|
18
|
+
var ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
|
|
19
|
+
var HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
20
|
+
var MomentLocalesPlugin = require('moment-locales-webpack-plugin');
|
|
21
|
+
var webpack = require('webpack');
|
|
22
|
+
var WebpackBar = require('webpackbar');
|
|
23
|
+
var _classCallCheck = require('@babel/runtime-corejs3/helpers/classCallCheck');
|
|
24
|
+
var _createClass = require('@babel/runtime-corejs3/helpers/createClass');
|
|
25
|
+
var _Object$assign = require('@babel/runtime-corejs3/core-js-stable/object/assign');
|
|
26
|
+
var applicationConfig = require('@commercetools-frontend/application-config');
|
|
27
|
+
var mcHtmlTemplate = require('@commercetools-frontend/mc-html-template');
|
|
28
|
+
var createPostcssConfig = require('./create-postcss-config-edca0c33.cjs.prod.js');
|
|
29
|
+
var hasJsxRuntime = require('./has-jsx-runtime-c3202df5.cjs.prod.js');
|
|
30
|
+
var optimizations = require('./optimizations-fb93514f.cjs.prod.js');
|
|
31
|
+
var paths = require('./paths-7768b440.cjs.prod.js');
|
|
32
|
+
var vendorsToTranspile = require('./vendors-to-transpile-04a49d40.cjs.prod.js');
|
|
33
|
+
|
|
34
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
35
|
+
|
|
36
|
+
var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
|
|
37
|
+
var _Object$getOwnPropertySymbols__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertySymbols);
|
|
38
|
+
var _Object$getOwnPropertyDescriptor__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptor);
|
|
39
|
+
var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachInstanceProperty);
|
|
40
|
+
var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
|
|
41
|
+
var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
|
|
42
|
+
var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
|
|
43
|
+
var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
|
|
44
|
+
var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
|
|
45
|
+
var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
|
|
46
|
+
var _endsWithInstanceProperty__default = /*#__PURE__*/_interopDefault(_endsWithInstanceProperty);
|
|
47
|
+
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
48
|
+
var crypto__default = /*#__PURE__*/_interopDefault(crypto);
|
|
49
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
50
|
+
var ReactRefreshWebpackPlugin__default = /*#__PURE__*/_interopDefault(ReactRefreshWebpackPlugin);
|
|
51
|
+
var HtmlWebpackPlugin__default = /*#__PURE__*/_interopDefault(HtmlWebpackPlugin);
|
|
52
|
+
var MomentLocalesPlugin__default = /*#__PURE__*/_interopDefault(MomentLocalesPlugin);
|
|
53
|
+
var webpack__default = /*#__PURE__*/_interopDefault(webpack);
|
|
54
|
+
var WebpackBar__default = /*#__PURE__*/_interopDefault(WebpackBar);
|
|
55
|
+
var _Object$assign__default = /*#__PURE__*/_interopDefault(_Object$assign);
|
|
56
|
+
|
|
57
|
+
let LocalHtmlWebpackPlugin = /*#__PURE__*/function () {
|
|
58
|
+
function LocalHtmlWebpackPlugin() {
|
|
59
|
+
_classCallCheck(this, LocalHtmlWebpackPlugin);
|
|
60
|
+
}
|
|
61
|
+
return _createClass(LocalHtmlWebpackPlugin, [{
|
|
62
|
+
key: "apply",
|
|
63
|
+
value: function apply(compiler) {
|
|
64
|
+
compiler.hooks.compilation.tap('LocalHtmlWebpackPlugin', compilation => {
|
|
65
|
+
HtmlWebpackPlugin__default["default"].getHooks(compilation).beforeEmit.tapAsync('LocalHtmlWebpackPlugin', async (data, cb) => {
|
|
66
|
+
try {
|
|
67
|
+
const applicationConfig$1 = await applicationConfig.processConfig();
|
|
68
|
+
const enhancedLocalEnv = _Object$assign__default["default"]({}, applicationConfig$1.env,
|
|
69
|
+
// Now that the app config is defined as a `env.json`, when we start the FE app
|
|
70
|
+
// to point to the local backend API by passing the `MC_API_URL` env does not
|
|
71
|
+
// work anymore). To make it work again, we can override the `env.json` config
|
|
72
|
+
// with the env variable before injecting the values into the index.html.
|
|
73
|
+
// NOTE: this is only necessary for development.
|
|
74
|
+
process.env.MC_API_URL ? {
|
|
75
|
+
mcApiUrl: process.env.MC_API_URL
|
|
76
|
+
} : {});
|
|
77
|
+
data.html = mcHtmlTemplate.replaceHtmlPlaceholders(data.html, {
|
|
78
|
+
env: enhancedLocalEnv
|
|
79
|
+
});
|
|
80
|
+
cb(null, data);
|
|
81
|
+
} catch (error) {
|
|
82
|
+
cb(error);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}]);
|
|
88
|
+
}();
|
|
89
|
+
|
|
90
|
+
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; }
|
|
91
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context6, _context7; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context6 = ownKeys(Object(t), !0)).call(_context6, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context7 = ownKeys(Object(t))).call(_context7, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
92
|
+
// https://babeljs.io/blog/2017/09/11/zero-config-with-babel-macros
|
|
93
|
+
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"];
|
|
94
|
+
const defaultToggleFlags = {
|
|
95
|
+
generateIndexHtml: true,
|
|
96
|
+
disableCoreJs: false
|
|
97
|
+
};
|
|
98
|
+
const defaultOptions = {
|
|
99
|
+
entryPoint: paths.paths.entryPoint,
|
|
100
|
+
sourceFolders: paths.paths.sourceFolders,
|
|
101
|
+
postcssOptions: {},
|
|
102
|
+
toggleFlags: defaultToggleFlags
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
// Whether or not `react-refresh` is enabled, `react-refresh` is not 100% stable at this time,
|
|
106
|
+
// which is why it's disabled by default.
|
|
107
|
+
const hasReactRefresh = process.env.FAST_REFRESH === 'true';
|
|
108
|
+
const webpackDevClientEntry = require.resolve('react-dev-utils/webpackHotDevClient');
|
|
109
|
+
const reactRefreshOverlayEntry = require.resolve('react-dev-utils/refreshOverlayInterop');
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* This is a factory function to create the default webpack config
|
|
113
|
+
* for a MC Application in `development` mode.
|
|
114
|
+
* The function requires the file path to the related application
|
|
115
|
+
* "entry point".
|
|
116
|
+
*/
|
|
117
|
+
function createWebpackConfigForDevelopment() {
|
|
118
|
+
var _context, _context2, _context3, _context4, _context5;
|
|
119
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
120
|
+
const mergedOptions = _objectSpread(_objectSpread(_objectSpread({}, defaultOptions), options), {}, {
|
|
121
|
+
toggleFlags: _objectSpread(_objectSpread({}, defaultToggleFlags), options.toggleFlags)
|
|
122
|
+
});
|
|
123
|
+
const appDependencies = require(paths.paths.appPackageJson).dependencies;
|
|
124
|
+
return {
|
|
125
|
+
// https://webpack.js.org/concepts/#mode
|
|
126
|
+
mode: 'development',
|
|
127
|
+
// Using `cheap-module-source-map` doesn't provide the original source when
|
|
128
|
+
// errors happen but it is still recommended as using `eval-source-map` leads
|
|
129
|
+
// to CORS errors when an error happens
|
|
130
|
+
// https://webpack.js.org/configuration/devtool/#devtool
|
|
131
|
+
// https://reactjs.org/docs/cross-origin-errors.html#source-maps
|
|
132
|
+
devtool: 'cheap-module-source-map',
|
|
133
|
+
// https://medium.com/webpack/webpack-4-code-splitting-chunk-graph-and-the-splitchunks-optimization-be739a861366
|
|
134
|
+
// https://medium.com/webpack/webpack-4-mode-and-optimization-5423a6bc597a
|
|
135
|
+
optimization: {
|
|
136
|
+
// Keep the runtime chunk separated to enable long term caching
|
|
137
|
+
// https://twitter.com/wSokra/status/969679223278505985
|
|
138
|
+
// https://github.com/facebook/create-react-app/issues/5358
|
|
139
|
+
runtimeChunk: {
|
|
140
|
+
name: 'runtime'
|
|
141
|
+
},
|
|
142
|
+
splitChunks: {
|
|
143
|
+
cacheGroups: optimizations.getWepbackCacheGroups(appDependencies)
|
|
144
|
+
},
|
|
145
|
+
moduleIds: 'named',
|
|
146
|
+
chunkIds: 'deterministic'
|
|
147
|
+
},
|
|
148
|
+
resolve: {
|
|
149
|
+
// These are the reasonable defaults supported by the Node ecosystem.
|
|
150
|
+
// We also include JSX as a common component filename extension to support
|
|
151
|
+
// some tools, although we do not recommend using it, see:
|
|
152
|
+
// https://github.com/facebook/create-react-app/issues/290
|
|
153
|
+
// `web` extension prefixes have been added for better support
|
|
154
|
+
// for React Native Web.
|
|
155
|
+
extensions: _mapInstanceProperty__default["default"](_context = ['js', 'mjs', 'cjs', 'ts', 'tsx', 'json', 'jsx']).call(_context, ext => `.${ext}`),
|
|
156
|
+
// NOTE: this is meant to be a temporary list of fallback/polyfills for certain
|
|
157
|
+
// nodejs modules. With Webpack <5 these polyfills were included by default in Webpack,
|
|
158
|
+
// however now it's not the case anymore.
|
|
159
|
+
// See also related work in CRA: https://github.com/facebook/create-react-app/pull/11764
|
|
160
|
+
fallback: {
|
|
161
|
+
url: require.resolve('url/'),
|
|
162
|
+
querystring: require.resolve('querystring-es3')
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
entry: {
|
|
166
|
+
app: _filterInstanceProperty__default["default"](_context2 = [require.resolve('@commercetools-frontend/mc-scripts/application-runtime'), !mergedOptions.toggleFlags.disableCoreJs && require.resolve('core-js/stable'),
|
|
167
|
+
// When using the experimental `react-refresh` integration,
|
|
168
|
+
// the webpack plugin takes care of injecting the dev client for us.
|
|
169
|
+
!hasReactRefresh &&
|
|
170
|
+
// Include an alternative client for WebpackDevServer. A client's job is to
|
|
171
|
+
// connect to WebpackDevServer by a socket and get notified about changes.
|
|
172
|
+
// When you save a file, the client will either apply hot updates (in case
|
|
173
|
+
// of CSS changes), or refresh the page (in case of JS changes). When you
|
|
174
|
+
// make a syntax error, this client will display a syntax error overlay.
|
|
175
|
+
// Note: instead of the default WebpackDevServer client, we use a custom one
|
|
176
|
+
// to bring better experience for Create React App users. You can replace
|
|
177
|
+
// the line below with these two lines if you prefer the stock client:
|
|
178
|
+
//
|
|
179
|
+
// require.resolve('webpack-dev-server/client') + '?/',
|
|
180
|
+
// require.resolve('webpack/hot/dev-server'),
|
|
181
|
+
webpackDevClientEntry,
|
|
182
|
+
// Finally, this is your app's code
|
|
183
|
+
mergedOptions.entryPoint
|
|
184
|
+
// We include the app code last so that if there is a runtime error during
|
|
185
|
+
// initialization, it doesn't blow up the WebpackDevServer client, and
|
|
186
|
+
// changing JS code would still trigger a refresh.
|
|
187
|
+
]).call(_context2, Boolean)
|
|
188
|
+
},
|
|
189
|
+
output: {
|
|
190
|
+
// This does not produce a real file. It's just the virtual path that is
|
|
191
|
+
// served by WebpackDevServer in development. This is the JS bundle
|
|
192
|
+
// containing code from all our entry points, and the Webpack runtime.
|
|
193
|
+
filename: '[name].js',
|
|
194
|
+
// There are also additional JS chunk files when using code splitting.
|
|
195
|
+
chunkFilename: '[name].chunk.js',
|
|
196
|
+
// The build folder.
|
|
197
|
+
path: paths.paths.appBuild,
|
|
198
|
+
// Add /* filename */ comments to generated require()s in the output.
|
|
199
|
+
pathinfo: true,
|
|
200
|
+
// This is the URL that app is served from. We use "/" in development.
|
|
201
|
+
publicPath: '/',
|
|
202
|
+
// Point sourcemap entries to the original disk location (format as URL on Windows)
|
|
203
|
+
devtoolModuleFilenameTemplate: info => path__default["default"].resolve(info.absoluteResourcePath).replace(/\\/g, '/')
|
|
204
|
+
},
|
|
205
|
+
plugins: _filterInstanceProperty__default["default"](_context3 = [new WebpackBar__default["default"](),
|
|
206
|
+
// Allows to "assign" custom options to the `webpack` object.
|
|
207
|
+
// At the moment, this is used to share some props with `postcss.config`.
|
|
208
|
+
new webpack__default["default"].LoaderOptionsPlugin({
|
|
209
|
+
options: {
|
|
210
|
+
sourceFolders: mergedOptions.sourceFolders,
|
|
211
|
+
context: __dirname
|
|
212
|
+
}
|
|
213
|
+
}),
|
|
214
|
+
// Makes some environment variables available to the JS code, for example:
|
|
215
|
+
// if (process.env.NODE_ENV === 'development') { ... }.
|
|
216
|
+
new webpack__default["default"].DefinePlugin({
|
|
217
|
+
__DEV__: 'true',
|
|
218
|
+
'process.env': {
|
|
219
|
+
NODE_ENV: _JSON$stringify__default["default"]('development')
|
|
220
|
+
}
|
|
221
|
+
}), mergedOptions.toggleFlags.generateIndexHtml && new HtmlWebpackPlugin__default["default"]({
|
|
222
|
+
inject: false,
|
|
223
|
+
filename: paths.paths.appIndexHtml,
|
|
224
|
+
template: require.resolve('@commercetools-frontend/mc-html-template/webpack')
|
|
225
|
+
}), mergedOptions.toggleFlags.generateIndexHtml && new LocalHtmlWebpackPlugin(),
|
|
226
|
+
// Only keep locales that are available in the Merchant Center.
|
|
227
|
+
new MomentLocalesPlugin__default["default"]({
|
|
228
|
+
localesToKeep: momentLocalesToKeep
|
|
229
|
+
}),
|
|
230
|
+
// This is necessary to emit hot updates (CSS and Fast Refresh):
|
|
231
|
+
new webpack__default["default"].HotModuleReplacementPlugin(),
|
|
232
|
+
// Experimental hot reloading for React .
|
|
233
|
+
// https://github.com/facebook/react/tree/master/packages/react-refresh
|
|
234
|
+
hasReactRefresh && new ReactRefreshWebpackPlugin__default["default"]({
|
|
235
|
+
overlay: {
|
|
236
|
+
entry: webpackDevClientEntry,
|
|
237
|
+
// The expected exports are slightly different from what the overlay exports,
|
|
238
|
+
// so an interop is included here to enable feedback on module-level errors.
|
|
239
|
+
module: reactRefreshOverlayEntry,
|
|
240
|
+
// Since we ship a custom dev client and overlay integration,
|
|
241
|
+
// the bundled socket handling logic can be eliminated.
|
|
242
|
+
sockIntegration: false
|
|
243
|
+
}
|
|
244
|
+
})]).call(_context3, Boolean),
|
|
245
|
+
module: {
|
|
246
|
+
// Makes missing exports an error instead of warning.
|
|
247
|
+
strictExportPresence: true,
|
|
248
|
+
rules: [
|
|
249
|
+
// For svg icons, we want to get them transformed into React components
|
|
250
|
+
// when we import them.
|
|
251
|
+
{
|
|
252
|
+
test: /\.react\.svg$/,
|
|
253
|
+
use: [{
|
|
254
|
+
loader: require.resolve('babel-loader'),
|
|
255
|
+
options: {
|
|
256
|
+
babelrc: false,
|
|
257
|
+
presets: [[require.resolve('@commercetools-frontend/babel-preset-mc-app'), {
|
|
258
|
+
runtime: hasJsxRuntime.hasJsxRuntime() ? 'automatic' : 'classic',
|
|
259
|
+
disableCoreJs: mergedOptions.toggleFlags.disableCoreJs
|
|
260
|
+
}]],
|
|
261
|
+
// This is a feature of `babel-loader` for webpack (not Babel itself).
|
|
262
|
+
// It enables caching results in ./node_modules/.cache/babel-loader/
|
|
263
|
+
// directory for faster rebuilds.
|
|
264
|
+
cacheDirectory: true,
|
|
265
|
+
highlightCode: true
|
|
266
|
+
}
|
|
267
|
+
}, {
|
|
268
|
+
loader: require.resolve('@svgr/webpack'),
|
|
269
|
+
options: {
|
|
270
|
+
icon: false,
|
|
271
|
+
svgoConfig: {
|
|
272
|
+
plugins: [{
|
|
273
|
+
// https://github.com/svg/svgo#default-preset
|
|
274
|
+
name: 'preset-default',
|
|
275
|
+
params: {
|
|
276
|
+
overrides: {
|
|
277
|
+
removeViewBox: false
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
},
|
|
281
|
+
// Avoid collisions with ids in other SVGs,
|
|
282
|
+
// which was causing incorrect masking, gradient directions, etc
|
|
283
|
+
// this is an ongoing issue with both SVGR and SVGO,
|
|
284
|
+
// https://github.com/svg/svgo/issues/913#issuecomment-369373572
|
|
285
|
+
// see SVGR issues:
|
|
286
|
+
// https://github.com/gregberge/svgr/issues/322
|
|
287
|
+
// https://github.com/gregberge/svgr/issues/210
|
|
288
|
+
// see SVGO issues:
|
|
289
|
+
// https://github.com/svg/svgo/issues/674
|
|
290
|
+
// https://github.com/svg/svgo/issues/1746
|
|
291
|
+
//
|
|
292
|
+
// Initially, a naive counter was implemented based on this github comment:
|
|
293
|
+
// https://github.com/svg/svgo/issues/1746#issuecomment-1803600573
|
|
294
|
+
// But while that implementation insured id’s that are unique,
|
|
295
|
+
// it did not work in cases where the id is both declared and referenced in the same file,
|
|
296
|
+
// because the refernce gets a separate unique ID (a different number from the counter).
|
|
297
|
+
//
|
|
298
|
+
// The current implementation is based on this github comment:
|
|
299
|
+
// https://github.com/svg/svgo/issues/913#issuecomment-369373572
|
|
300
|
+
// Generates a hash of the filepath of the svg file, resulting in a prefix which is:
|
|
301
|
+
// - Short,
|
|
302
|
+
// - With characters valid for IDs,
|
|
303
|
+
// - The same within a file,
|
|
304
|
+
// - And different in different files.
|
|
305
|
+
{
|
|
306
|
+
name: 'prefixIds',
|
|
307
|
+
params: {
|
|
308
|
+
delim: '',
|
|
309
|
+
prefix: (_, info) => `svg${crypto__default["default"].createHash('shake256', {
|
|
310
|
+
outputLength: 6
|
|
311
|
+
}).update(info.path || '').digest('hex')}`
|
|
312
|
+
}
|
|
313
|
+
}]
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}]
|
|
317
|
+
},
|
|
318
|
+
// For normal svg files (not icons) we should load the file normally
|
|
319
|
+
// and simply use it as a `<img src/>`.
|
|
320
|
+
{
|
|
321
|
+
test: function testForNormalSvgFiles(fileName) {
|
|
322
|
+
return (
|
|
323
|
+
// Use this only for plain SVG.
|
|
324
|
+
// For SVG as React components, see loader above.
|
|
325
|
+
_endsWithInstanceProperty__default["default"](fileName).call(fileName, '.svg') && !_endsWithInstanceProperty__default["default"](fileName).call(fileName, '.react.svg')
|
|
326
|
+
);
|
|
327
|
+
},
|
|
328
|
+
use: [{
|
|
329
|
+
loader: require.resolve('svg-url-loader')
|
|
330
|
+
}]
|
|
331
|
+
}, {
|
|
332
|
+
test: /\.png$/,
|
|
333
|
+
type: 'asset/resource'
|
|
334
|
+
},
|
|
335
|
+
// "postcss" loader applies autoprefixer to our CSS
|
|
336
|
+
// "css" loader resolves paths in CSS and adds assets as dependencies.
|
|
337
|
+
// "style" loader turns CSS into JS modules that inject <style> tags.
|
|
338
|
+
{
|
|
339
|
+
test: /\.(mod|module)\.css$/,
|
|
340
|
+
include: mergedOptions.sourceFolders,
|
|
341
|
+
use: [require.resolve('style-loader'), {
|
|
342
|
+
loader: require.resolve('css-loader'),
|
|
343
|
+
options: {
|
|
344
|
+
modules: {
|
|
345
|
+
mode: 'local',
|
|
346
|
+
localIdentName: '[name]__[local]___[hash:base64:5]',
|
|
347
|
+
localIdentHashSalt: 'ct'
|
|
348
|
+
},
|
|
349
|
+
importLoaders: 1
|
|
350
|
+
}
|
|
351
|
+
}, {
|
|
352
|
+
loader: require.resolve('postcss-loader'),
|
|
353
|
+
options: {
|
|
354
|
+
postcssOptions: createPostcssConfig.createPostcssConfig(mergedOptions.postcssOptions)
|
|
355
|
+
}
|
|
356
|
+
}]
|
|
357
|
+
}, {
|
|
358
|
+
test: function testForNormalCssFiles(fileName) {
|
|
359
|
+
return (
|
|
360
|
+
// Use this only for plain CSS.
|
|
361
|
+
// For css-modules, see loader above.
|
|
362
|
+
_endsWithInstanceProperty__default["default"](fileName).call(fileName, '.css') && !(_endsWithInstanceProperty__default["default"](fileName).call(fileName, '.mod.css') || _endsWithInstanceProperty__default["default"](fileName).call(fileName, '.module.css'))
|
|
363
|
+
);
|
|
364
|
+
},
|
|
365
|
+
// "postcss" loader applies autoprefixer to our CSS.
|
|
366
|
+
// "css" loader resolves paths in CSS and adds assets as dependencies.
|
|
367
|
+
// "style" loader turns CSS into JS modules that inject <style> tags.
|
|
368
|
+
oneOf: [{
|
|
369
|
+
// Use "postcss" for all the included source folders.
|
|
370
|
+
include: mergedOptions.sourceFolders,
|
|
371
|
+
use: [require.resolve('style-loader'), {
|
|
372
|
+
loader: require.resolve('css-loader'),
|
|
373
|
+
options: {
|
|
374
|
+
modules: {
|
|
375
|
+
mode: 'icss'
|
|
376
|
+
},
|
|
377
|
+
importLoaders: 1
|
|
378
|
+
}
|
|
379
|
+
}, {
|
|
380
|
+
loader: require.resolve('postcss-loader'),
|
|
381
|
+
options: {
|
|
382
|
+
postcssOptions: createPostcssConfig.createPostcssConfig(mergedOptions.postcssOptions)
|
|
383
|
+
}
|
|
384
|
+
}]
|
|
385
|
+
}, {
|
|
386
|
+
// For all other vendor CSS, do not use "postcss" loader.
|
|
387
|
+
include: /node_modules/,
|
|
388
|
+
use: [require.resolve('style-loader'), {
|
|
389
|
+
loader: require.resolve('css-loader'),
|
|
390
|
+
options: {
|
|
391
|
+
modules: {
|
|
392
|
+
mode: 'icss'
|
|
393
|
+
},
|
|
394
|
+
importLoaders: 1
|
|
395
|
+
}
|
|
396
|
+
}],
|
|
397
|
+
// Don't consider CSS imports dead code even if the
|
|
398
|
+
// containing package claims to have no side effects.
|
|
399
|
+
// Remove this when webpack adds a warning or an error for this.
|
|
400
|
+
// See https://github.com/webpack/webpack/issues/6571
|
|
401
|
+
sideEffects: true
|
|
402
|
+
}]
|
|
403
|
+
},
|
|
404
|
+
// Fix for react-intl
|
|
405
|
+
// https://github.com/formatjs/formatjs/issues/143#issuecomment-518774786
|
|
406
|
+
{
|
|
407
|
+
test: /\.mjs$/,
|
|
408
|
+
type: 'javascript/auto',
|
|
409
|
+
resolve: {
|
|
410
|
+
// https://webpack.js.org/configuration/module/#resolvefullyspecified
|
|
411
|
+
fullySpecified: false
|
|
412
|
+
}
|
|
413
|
+
},
|
|
414
|
+
// Process JS with Babel.
|
|
415
|
+
{
|
|
416
|
+
test: /\.(js|mjs|cjs|jsx|ts|tsx)$/,
|
|
417
|
+
use: [
|
|
418
|
+
// This loader parallelizes code compilation, it is optional but
|
|
419
|
+
// improves compile time on larger projects
|
|
420
|
+
{
|
|
421
|
+
loader: require.resolve('thread-loader'),
|
|
422
|
+
options: {
|
|
423
|
+
poolTimeout: Infinity // keep workers alive for more effective watch mode
|
|
424
|
+
}
|
|
425
|
+
}, {
|
|
426
|
+
loader: require.resolve('babel-loader'),
|
|
427
|
+
options: {
|
|
428
|
+
babelrc: false,
|
|
429
|
+
configFile: false,
|
|
430
|
+
compact: false,
|
|
431
|
+
presets: [[require.resolve('@commercetools-frontend/babel-preset-mc-app'), {
|
|
432
|
+
runtime: hasJsxRuntime.hasJsxRuntime() ? 'automatic' : 'classic'
|
|
433
|
+
}]],
|
|
434
|
+
plugins: _filterInstanceProperty__default["default"](_context4 = [hasReactRefresh && require.resolve('react-refresh/babel')]).call(_context4, Boolean),
|
|
435
|
+
// This is a feature of `babel-loader` for webpack (not Babel itself).
|
|
436
|
+
// It enables caching results in ./node_modules/.cache/babel-loader/
|
|
437
|
+
// directory for faster rebuilds.
|
|
438
|
+
cacheDirectory: true,
|
|
439
|
+
highlightCode: true
|
|
440
|
+
}
|
|
441
|
+
}],
|
|
442
|
+
include: _concatInstanceProperty__default["default"](_context5 = mergedOptions.sourceFolders).call(_context5, vendorsToTranspile.vendorsToTranspile),
|
|
443
|
+
// Disable require.ensure as it's not a standard language feature.
|
|
444
|
+
parser: {
|
|
445
|
+
requireEnsure: false
|
|
446
|
+
}
|
|
447
|
+
},
|
|
448
|
+
// Allow to import `*.graphql` SDL files.
|
|
449
|
+
{
|
|
450
|
+
test: /\.graphql$/,
|
|
451
|
+
include: mergedOptions.sourceFolders,
|
|
452
|
+
use: [require.resolve('graphql-tag/loader')]
|
|
453
|
+
}]
|
|
454
|
+
},
|
|
455
|
+
// Turn off performance processing because we utilize
|
|
456
|
+
// our own hints via the FileSizeReporter
|
|
457
|
+
performance: false,
|
|
458
|
+
// For dev server
|
|
459
|
+
infrastructureLogging: {
|
|
460
|
+
level: 'none'
|
|
461
|
+
}
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
exports.createWebpackConfigForDevelopment = createWebpackConfigForDevelopment;
|