@commercetools-frontend/mc-scripts 21.7.0 → 21.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +1 -42
- package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.d.ts +1 -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/{build/config/application-runtime.js → application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.prod.js} +2 -2
- 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 +1 -1
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.d.ts +1 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.dev.js +361 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.js +7 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.prod.js +361 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.esm.js +345 -0
- package/cli/package.json +4 -0
- package/config/create-webpack-config-for-development.js +7 -1
- package/config/create-webpack-config-for-production.js +7 -1
- package/config/vendors-to-transpile.js +5 -1
- package/dist/build-5357ad26.cjs.prod.js +224 -0
- package/dist/build-9b6d7eee.cjs.dev.js +224 -0
- package/dist/build-c483e87f.esm.js +209 -0
- package/dist/build-vite-3b82522e.cjs.dev.js +151 -0
- package/dist/build-vite-93abdc95.esm.js +139 -0
- package/dist/build-vite-b7cd993a.cjs.prod.js +151 -0
- package/dist/commercetools-frontend-mc-scripts.cjs.d.ts +1 -0
- package/dist/commercetools-frontend-mc-scripts.cjs.dev.js +30 -0
- package/dist/commercetools-frontend-mc-scripts.cjs.js +7 -0
- package/dist/commercetools-frontend-mc-scripts.cjs.prod.js +30 -0
- package/dist/commercetools-frontend-mc-scripts.esm.js +22 -0
- package/dist/compile-html-4361a0b3.esm.js +77 -0
- package/dist/compile-html-d6331c35.cjs.prod.js +87 -0
- package/dist/compile-html-d9e731aa.cjs.dev.js +87 -0
- package/dist/config-sync-6b31d972.esm.js +840 -0
- package/dist/config-sync-a478bc0f.cjs.dev.js +864 -0
- package/dist/config-sync-f07734e4.cjs.prod.js +859 -0
- package/{build/config/create-postcss-config.js → dist/create-postcss-config-04243dea.esm.js} +27 -25
- package/dist/create-postcss-config-760e2dc5.cjs.dev.js +90 -0
- package/dist/create-postcss-config-ddc3abee.cjs.prod.js +90 -0
- package/dist/create-webpack-config-for-development-76fdab59.cjs.prod.js +419 -0
- package/{build/config/create-webpack-config-for-development.js → dist/create-webpack-config-for-development-d93ae4b2.esm.js} +94 -57
- package/dist/create-webpack-config-for-development-dfd1c174.cjs.dev.js +419 -0
- package/{build/config/create-webpack-config-for-production.js → dist/create-webpack-config-for-production-9290479a.esm.js} +120 -54
- package/dist/create-webpack-config-for-production-bc8c1f37.cjs.dev.js +469 -0
- package/dist/create-webpack-config-for-production-d652ad1a.cjs.prod.js +469 -0
- package/dist/declarations/src/application-runtime.d.ts +1 -0
- package/dist/declarations/src/cli.d.ts +4 -0
- package/dist/declarations/src/commands/build-vite.d.ts +2 -0
- package/dist/declarations/src/commands/build.d.ts +2 -0
- package/dist/declarations/src/commands/compile-html.d.ts +3 -0
- package/dist/declarations/src/commands/config-sync.d.ts +3 -0
- package/dist/declarations/src/commands/login.d.ts +2 -0
- package/dist/declarations/src/commands/serve.d.ts +2 -0
- package/dist/declarations/src/commands/start-vite.d.ts +2 -0
- package/dist/declarations/src/commands/start.d.ts +2 -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/has-jsx-runtime.d.ts +2 -0
- package/dist/declarations/src/config/moment-locales.d.ts +2 -0
- package/dist/declarations/src/config/paths.d.ts +12 -0
- package/dist/declarations/src/config/vendors-to-transpile.d.ts +2 -0
- package/dist/declarations/src/config/webpack-dev-server.config.d.ts +6 -0
- package/dist/declarations/src/deprecated-entry-points.d.ts +7 -0
- package/dist/declarations/src/generated/core.d.ts +710 -0
- package/dist/declarations/src/generated/settings.d.ts +2485 -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 +82 -0
- package/dist/declarations/src/utils/auth.d.ts +6 -0
- package/dist/declarations/src/utils/credentials-storage.d.ts +11 -0
- package/dist/declarations/src/utils/get-config-diff.d.ts +3 -0
- package/dist/declarations/src/utils/graphql-requests.d.ts +80 -0
- package/dist/declarations/src/utils/user-agent.d.ts +2 -0
- package/dist/declarations/src/version.d.ts +2 -0
- package/dist/declarations/src/vite-plugins/vite-plugin-custom-application.d.ts +4 -0
- package/dist/declarations/src/vite-plugins/vite-plugin-dynamic-base-assets-globals.d.ts +3 -0
- package/dist/declarations/src/vite-plugins/vite-plugin-svgr.d.ts +3 -0
- package/dist/declarations/src/webpack-plugins/final-stats-writer-plugin.d.ts +12 -0
- package/dist/declarations/src/webpack-plugins/local-html-webpack-plugin.d.ts +5 -0
- package/dist/declarations/src/webpack.d.ts +2 -0
- package/dist/has-jsx-runtime-0b03b72e.cjs.prod.js +17 -0
- package/dist/has-jsx-runtime-3d4bb633.cjs.dev.js +17 -0
- package/{build/config/has-jsx-runtime.js → dist/has-jsx-runtime-8314226e.esm.js} +1 -3
- package/dist/login-7b7ae27e.esm.js +155 -0
- package/dist/login-b13f26e7.cjs.dev.js +165 -0
- package/dist/login-c11fb977.cjs.prod.js +165 -0
- package/dist/package-4b4fcf02.cjs.prod.js +139 -0
- package/dist/package-4c3e3fb7.cjs.dev.js +139 -0
- package/dist/package-8e6305bd.esm.js +137 -0
- package/dist/paths-16823f56.cjs.dev.js +55 -0
- package/dist/paths-76b66e74.cjs.prod.js +55 -0
- package/dist/paths-ed23d5a1.esm.js +46 -0
- package/dist/serve-12de323b.cjs.dev.js +70 -0
- package/dist/serve-784f4fcd.cjs.prod.js +70 -0
- package/dist/serve-d6b437b1.esm.js +62 -0
- package/dist/start-1b7dad90.cjs.prod.js +209 -0
- package/dist/start-45ca01f2.cjs.dev.js +209 -0
- package/dist/start-600d06a3.esm.js +194 -0
- package/dist/start-vite-22de08dc.cjs.dev.js +151 -0
- package/dist/start-vite-dc046cba.esm.js +138 -0
- package/dist/start-vite-fe13330b.cjs.prod.js +151 -0
- package/dist/user-agent-5f8ec93d.cjs.prod.js +106 -0
- package/dist/user-agent-ca628320.esm.js +94 -0
- package/dist/user-agent-ee57c98a.cjs.dev.js +106 -0
- package/dist/vendors-to-transpile-367e0ba8.cjs.prod.js +5 -0
- package/dist/vendors-to-transpile-68e03526.esm.js +3 -0
- package/dist/vendors-to-transpile-b51af5d3.cjs.dev.js +5 -0
- package/dist/vite-plugin-svgr-4205f2b5.cjs.dev.js +110 -0
- package/dist/vite-plugin-svgr-eb8524fa.esm.js +85 -0
- package/dist/vite-plugin-svgr-f3bbedbe.cjs.prod.js +110 -0
- package/package.json +56 -50
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.d.ts +1 -0
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.dev.js +14 -0
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.js +7 -0
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.prod.js +14 -0
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.esm.js +6 -0
- package/postcss/package.json +4 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.d.ts +1 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.dev.js +51 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.js +7 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.prod.js +51 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.esm.js +42 -0
- package/webpack/package.json +4 -0
- package/build/bin/cli.js +0 -264
- package/build/commands/build-vite.js +0 -91
- package/build/commands/build.js +0 -140
- package/build/commands/compile-html.js +0 -53
- package/build/commands/config-sync.js +0 -176
- package/build/commands/login.js +0 -60
- package/build/commands/serve.js +0 -37
- package/build/commands/start-vite.js +0 -138
- package/build/commands/start.js +0 -108
- package/build/config/paths.js +0 -38
- package/build/config/vendors-to-transpile.js +0 -3
- package/build/config/webpack-dev-server.config.js +0 -69
- package/build/index.js +0 -16
- package/build/utils/auth.js +0 -34
- package/build/utils/auth.spec.js +0 -61
- package/build/utils/create-custom-application.settings.graphql +0 -8
- package/build/utils/credentials-storage.js +0 -72
- package/build/utils/credentials-storage.spec.js +0 -69
- package/build/utils/fetch-custom-application.settings.graphql +0 -36
- package/build/utils/fetch-user-organizations.core.graphql +0 -9
- package/build/utils/get-config-diff.js +0 -308
- package/build/utils/get-config-diff.spec.js +0 -285
- package/build/utils/graphql-requests.js +0 -105
- package/build/utils/graphql-requests.spec.js +0 -159
- package/build/utils/require-graphql.js +0 -15
- package/build/utils/update-custom-application.settings.graphql +0 -13
- package/build/utils/user-agent.js +0 -15
- package/build/webpack-plugins/final-stats-writer-plugin.js +0 -50
- package/build/webpack-plugins/local-html-webpack-plugin.js +0 -38
|
@@ -0,0 +1,419 @@
|
|
|
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 path = require('path');
|
|
17
|
+
var webpack = require('webpack');
|
|
18
|
+
var WebpackBar = require('webpackbar');
|
|
19
|
+
var HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
20
|
+
var MomentLocalesPlugin = require('moment-locales-webpack-plugin');
|
|
21
|
+
var ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
|
|
22
|
+
var _classCallCheck = require('@babel/runtime-corejs3/helpers/classCallCheck');
|
|
23
|
+
var _createClass = require('@babel/runtime-corejs3/helpers/createClass');
|
|
24
|
+
var _Object$assign = require('@babel/runtime-corejs3/core-js-stable/object/assign');
|
|
25
|
+
var applicationConfig = require('@commercetools-frontend/application-config');
|
|
26
|
+
var mcHtmlTemplate = require('@commercetools-frontend/mc-html-template');
|
|
27
|
+
var paths = require('./paths-76b66e74.cjs.prod.js');
|
|
28
|
+
var vendorsToTranspile = require('./vendors-to-transpile-367e0ba8.cjs.prod.js');
|
|
29
|
+
var createPostcssConfig = require('./create-postcss-config-ddc3abee.cjs.prod.js');
|
|
30
|
+
var hasJsxRuntime = require('./has-jsx-runtime-0b03b72e.cjs.prod.js');
|
|
31
|
+
|
|
32
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
33
|
+
|
|
34
|
+
var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
|
|
35
|
+
var _Object$getOwnPropertySymbols__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertySymbols);
|
|
36
|
+
var _Object$getOwnPropertyDescriptor__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptor);
|
|
37
|
+
var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachInstanceProperty);
|
|
38
|
+
var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
|
|
39
|
+
var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
|
|
40
|
+
var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
|
|
41
|
+
var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
|
|
42
|
+
var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
|
|
43
|
+
var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
|
|
44
|
+
var _endsWithInstanceProperty__default = /*#__PURE__*/_interopDefault(_endsWithInstanceProperty);
|
|
45
|
+
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
46
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
47
|
+
var webpack__default = /*#__PURE__*/_interopDefault(webpack);
|
|
48
|
+
var WebpackBar__default = /*#__PURE__*/_interopDefault(WebpackBar);
|
|
49
|
+
var HtmlWebpackPlugin__default = /*#__PURE__*/_interopDefault(HtmlWebpackPlugin);
|
|
50
|
+
var MomentLocalesPlugin__default = /*#__PURE__*/_interopDefault(MomentLocalesPlugin);
|
|
51
|
+
var ReactRefreshWebpackPlugin__default = /*#__PURE__*/_interopDefault(ReactRefreshWebpackPlugin);
|
|
52
|
+
var _Object$assign__default = /*#__PURE__*/_interopDefault(_Object$assign);
|
|
53
|
+
|
|
54
|
+
var LocalHtmlWebpackPlugin = /*#__PURE__*/function () {
|
|
55
|
+
function LocalHtmlWebpackPlugin() {
|
|
56
|
+
_classCallCheck(this, LocalHtmlWebpackPlugin);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
_createClass(LocalHtmlWebpackPlugin, [{
|
|
60
|
+
key: "apply",
|
|
61
|
+
value: function apply(compiler) {
|
|
62
|
+
compiler.hooks.compilation.tap('LocalHtmlWebpackPlugin', function (compilation) {
|
|
63
|
+
HtmlWebpackPlugin__default["default"].getHooks(compilation).beforeEmit.tapAsync('LocalHtmlWebpackPlugin', function (data, cb) {
|
|
64
|
+
var applicationConfig$1 = applicationConfig.processConfig();
|
|
65
|
+
|
|
66
|
+
var enhancedLocalEnv = _Object$assign__default["default"]({}, applicationConfig$1.env, // Now that the app config is defined as a `env.json`, when we start the FE app
|
|
67
|
+
// to point to the local backend API by passing the `MC_API_URL` env does not
|
|
68
|
+
// work anymore). To make it work again, we can override the `env.json` config
|
|
69
|
+
// with the env variable before injecting the values into the index.html.
|
|
70
|
+
// NOTE: this is only necessary for development.
|
|
71
|
+
process.env.MC_API_URL ? {
|
|
72
|
+
mcApiUrl: process.env.MC_API_URL
|
|
73
|
+
} : {});
|
|
74
|
+
|
|
75
|
+
data.html = mcHtmlTemplate.replaceHtmlPlaceholders(data.html, {
|
|
76
|
+
env: enhancedLocalEnv,
|
|
77
|
+
headers: {}
|
|
78
|
+
});
|
|
79
|
+
cb(null, data);
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}]);
|
|
84
|
+
|
|
85
|
+
return LocalHtmlWebpackPlugin;
|
|
86
|
+
}();
|
|
87
|
+
|
|
88
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
89
|
+
|
|
90
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context6, _context7; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context6 = ownKeys(Object(source), !0)).call(_context6, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context7 = ownKeys(Object(source))).call(_context7, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
|
|
91
|
+
|
|
92
|
+
var 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", "ja", "zh-cn"];
|
|
93
|
+
var defaultToggleFlags = {
|
|
94
|
+
generateIndexHtml: true,
|
|
95
|
+
disableCoreJs: false
|
|
96
|
+
};
|
|
97
|
+
var defaultOptions = {
|
|
98
|
+
entryPoint: paths.paths.entryPoint,
|
|
99
|
+
sourceFolders: paths.paths.sourceFolders,
|
|
100
|
+
postcssOptions: {},
|
|
101
|
+
toggleFlags: defaultToggleFlags
|
|
102
|
+
}; // Whether or not `react-refresh` is enabled, `react-refresh` is not 100% stable at this time,
|
|
103
|
+
// which is why it's disabled by default.
|
|
104
|
+
|
|
105
|
+
var hasReactRefresh = process.env.FAST_REFRESH === 'true';
|
|
106
|
+
|
|
107
|
+
var webpackDevClientEntry = require.resolve('react-dev-utils/webpackHotDevClient');
|
|
108
|
+
|
|
109
|
+
var reactRefreshOverlayEntry = require.resolve('react-dev-utils/refreshOverlayInterop');
|
|
110
|
+
/**
|
|
111
|
+
* This is a factory function to create the default webpack config
|
|
112
|
+
* for a MC Application in `development` mode.
|
|
113
|
+
* The function requires the file path to the related application
|
|
114
|
+
* "entry point".
|
|
115
|
+
*/
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
function createWebpackConfigForDevelopment() {
|
|
119
|
+
var _context, _context2, _context3, _context4, _context5;
|
|
120
|
+
|
|
121
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
122
|
+
|
|
123
|
+
var mergedOptions = _objectSpread(_objectSpread(_objectSpread({}, defaultOptions), options), {}, {
|
|
124
|
+
toggleFlags: _objectSpread(_objectSpread({}, defaultToggleFlags), options.toggleFlags)
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
return {
|
|
128
|
+
// https://webpack.js.org/concepts/#mode
|
|
129
|
+
mode: 'development',
|
|
130
|
+
// Using `cheap-module-source-map` doesn't provide the original source when
|
|
131
|
+
// errors happen but it is still recommended as using `eval-source-map` leads
|
|
132
|
+
// to CORS errors when an error happens
|
|
133
|
+
// https://webpack.js.org/configuration/devtool/#devtool
|
|
134
|
+
// https://reactjs.org/docs/cross-origin-errors.html#source-maps
|
|
135
|
+
devtool: 'cheap-module-source-map',
|
|
136
|
+
// https://medium.com/webpack/webpack-4-code-splitting-chunk-graph-and-the-splitchunks-optimization-be739a861366
|
|
137
|
+
// https://medium.com/webpack/webpack-4-mode-and-optimization-5423a6bc597a
|
|
138
|
+
optimization: {
|
|
139
|
+
// Automatically split vendor and commons
|
|
140
|
+
// https://twitter.com/wSokra/status/969633336732905474
|
|
141
|
+
splitChunks: {
|
|
142
|
+
chunks: 'all'
|
|
143
|
+
},
|
|
144
|
+
// Keep the runtime chunk separated to enable long term caching
|
|
145
|
+
// https://twitter.com/wSokra/status/969679223278505985
|
|
146
|
+
// https://github.com/facebook/create-react-app/issues/5358
|
|
147
|
+
runtimeChunk: {
|
|
148
|
+
name: 'runtime'
|
|
149
|
+
},
|
|
150
|
+
moduleIds: 'named',
|
|
151
|
+
chunkIds: 'deterministic'
|
|
152
|
+
},
|
|
153
|
+
resolve: {
|
|
154
|
+
// These are the reasonable defaults supported by the Node ecosystem.
|
|
155
|
+
// We also include JSX as a common component filename extension to support
|
|
156
|
+
// some tools, although we do not recommend using it, see:
|
|
157
|
+
// https://github.com/facebook/create-react-app/issues/290
|
|
158
|
+
// `web` extension prefixes have been added for better support
|
|
159
|
+
// for React Native Web.
|
|
160
|
+
extensions: _mapInstanceProperty__default["default"](_context = ['js', 'mjs', 'cjs', 'ts', 'tsx', 'json', 'jsx']).call(_context, function (ext) {
|
|
161
|
+
return ".".concat(ext);
|
|
162
|
+
}),
|
|
163
|
+
// NOTE: this is meant to be a temporary list of fallback/polyfills for certain
|
|
164
|
+
// nodejs modules. With Webpack <5 these polyfills were included by default in Webpack,
|
|
165
|
+
// however now it's not the case anymore.
|
|
166
|
+
// See also related work in CRA: https://github.com/facebook/create-react-app/pull/11764
|
|
167
|
+
fallback: {
|
|
168
|
+
url: require.resolve('url/'),
|
|
169
|
+
querystring: require.resolve('querystring-es3')
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
entry: {
|
|
173
|
+
app: _filterInstanceProperty__default["default"](_context2 = [require.resolve('@commercetools-frontend/mc-scripts/application-runtime'), !mergedOptions.toggleFlags.disableCoreJs && require.resolve('core-js/stable'), // When using the experimental `react-refresh` integration,
|
|
174
|
+
// the webpack plugin takes care of injecting the dev client for us.
|
|
175
|
+
!hasReactRefresh && // Include an alternative client for WebpackDevServer. A client's job is to
|
|
176
|
+
// connect to WebpackDevServer by a socket and get notified about changes.
|
|
177
|
+
// When you save a file, the client will either apply hot updates (in case
|
|
178
|
+
// of CSS changes), or refresh the page (in case of JS changes). When you
|
|
179
|
+
// make a syntax error, this client will display a syntax error overlay.
|
|
180
|
+
// Note: instead of the default WebpackDevServer client, we use a custom one
|
|
181
|
+
// to bring better experience for Create React App users. You can replace
|
|
182
|
+
// the line below with these two lines if you prefer the stock client:
|
|
183
|
+
//
|
|
184
|
+
// require.resolve('webpack-dev-server/client') + '?/',
|
|
185
|
+
// require.resolve('webpack/hot/dev-server'),
|
|
186
|
+
webpackDevClientEntry, // Finally, this is your app's code
|
|
187
|
+
mergedOptions.entryPoint // We include the app code last so that if there is a runtime error during
|
|
188
|
+
// initialization, it doesn't blow up the WebpackDevServer client, and
|
|
189
|
+
// changing JS code would still trigger a refresh.
|
|
190
|
+
]).call(_context2, Boolean)
|
|
191
|
+
},
|
|
192
|
+
output: {
|
|
193
|
+
// This does not produce a real file. It's just the virtual path that is
|
|
194
|
+
// served by WebpackDevServer in development. This is the JS bundle
|
|
195
|
+
// containing code from all our entry points, and the Webpack runtime.
|
|
196
|
+
filename: '[name].js',
|
|
197
|
+
// There are also additional JS chunk files when using code splitting.
|
|
198
|
+
chunkFilename: '[name].chunk.js',
|
|
199
|
+
// The build folder.
|
|
200
|
+
path: paths.paths.appBuild,
|
|
201
|
+
// Add /* filename */ comments to generated require()s in the output.
|
|
202
|
+
pathinfo: true,
|
|
203
|
+
// This is the URL that app is served from. We use "/" in development.
|
|
204
|
+
publicPath: '/',
|
|
205
|
+
// Point sourcemap entries to the original disk location (format as URL on Windows)
|
|
206
|
+
devtoolModuleFilenameTemplate: function devtoolModuleFilenameTemplate(info) {
|
|
207
|
+
return path__default["default"].resolve(info.absoluteResourcePath).replace(/\\/g, '/');
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
plugins: _filterInstanceProperty__default["default"](_context3 = [new WebpackBar__default["default"](), // Allows to "assign" custom options to the `webpack` object.
|
|
211
|
+
// At the moment, this is used to share some props with `postcss.config`.
|
|
212
|
+
new webpack__default["default"].LoaderOptionsPlugin({
|
|
213
|
+
options: {
|
|
214
|
+
sourceFolders: mergedOptions.sourceFolders,
|
|
215
|
+
context: __dirname
|
|
216
|
+
}
|
|
217
|
+
}), // Makes some environment variables available to the JS code, for example:
|
|
218
|
+
// if (process.env.NODE_ENV === 'development') { ... }.
|
|
219
|
+
new webpack__default["default"].DefinePlugin({
|
|
220
|
+
__DEV__: 'true',
|
|
221
|
+
'process.env': {
|
|
222
|
+
NODE_ENV: _JSON$stringify__default["default"]('development')
|
|
223
|
+
}
|
|
224
|
+
}), mergedOptions.toggleFlags.generateIndexHtml && new HtmlWebpackPlugin__default["default"]({
|
|
225
|
+
inject: false,
|
|
226
|
+
filename: paths.paths.appIndexHtml,
|
|
227
|
+
template: require.resolve('@commercetools-frontend/mc-html-template/webpack')
|
|
228
|
+
}), mergedOptions.toggleFlags.generateIndexHtml && new LocalHtmlWebpackPlugin(), // Only keep locales that are available in the Merchant Center.
|
|
229
|
+
new MomentLocalesPlugin__default["default"]({
|
|
230
|
+
localesToKeep: momentLocalesToKeep
|
|
231
|
+
}), // This is necessary to emit hot updates (CSS and Fast Refresh):
|
|
232
|
+
new webpack__default["default"].HotModuleReplacementPlugin(), // 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: [// For svg icons, we want to get them transformed into React components
|
|
249
|
+
// when we import them.
|
|
250
|
+
{
|
|
251
|
+
test: /\.react\.svg$/,
|
|
252
|
+
use: [{
|
|
253
|
+
loader: require.resolve('babel-loader'),
|
|
254
|
+
options: {
|
|
255
|
+
babelrc: false,
|
|
256
|
+
presets: [[require.resolve('@commercetools-frontend/babel-preset-mc-app'), {
|
|
257
|
+
runtime: hasJsxRuntime.hasJsxRuntime() ? 'automatic' : 'classic',
|
|
258
|
+
disableCoreJs: mergedOptions.toggleFlags.disableCoreJs
|
|
259
|
+
}]],
|
|
260
|
+
// This is a feature of `babel-loader` for webpack (not Babel itself).
|
|
261
|
+
// It enables caching results in ./node_modules/.cache/babel-loader/
|
|
262
|
+
// directory for faster rebuilds.
|
|
263
|
+
cacheDirectory: true,
|
|
264
|
+
highlightCode: true
|
|
265
|
+
}
|
|
266
|
+
}, {
|
|
267
|
+
loader: require.resolve('@svgr/webpack'),
|
|
268
|
+
options: {
|
|
269
|
+
icon: false,
|
|
270
|
+
svgoConfig: {
|
|
271
|
+
plugins: [{
|
|
272
|
+
// https://github.com/svg/svgo#default-preset
|
|
273
|
+
name: 'preset-default',
|
|
274
|
+
params: {
|
|
275
|
+
overrides: {
|
|
276
|
+
removeViewBox: false
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}]
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}]
|
|
283
|
+
}, // For normal svg files (not icons) we should load the file normally
|
|
284
|
+
// and simply use it as a `<img src/>`.
|
|
285
|
+
{
|
|
286
|
+
test: function testForNormalSvgFiles(fileName) {
|
|
287
|
+
return (// Use this only for plain SVG.
|
|
288
|
+
// For SVG as React components, see loader above.
|
|
289
|
+
_endsWithInstanceProperty__default["default"](fileName).call(fileName, '.svg') && !_endsWithInstanceProperty__default["default"](fileName).call(fileName, '.react.svg')
|
|
290
|
+
);
|
|
291
|
+
},
|
|
292
|
+
use: [{
|
|
293
|
+
loader: require.resolve('svg-url-loader')
|
|
294
|
+
}]
|
|
295
|
+
}, {
|
|
296
|
+
test: /\.png$/,
|
|
297
|
+
type: 'asset/resource'
|
|
298
|
+
}, // "postcss" loader applies autoprefixer to our CSS
|
|
299
|
+
// "css" loader resolves paths in CSS and adds assets as dependencies.
|
|
300
|
+
// "style" loader turns CSS into JS modules that inject <style> tags.
|
|
301
|
+
{
|
|
302
|
+
test: /\.(mod|module)\.css$/,
|
|
303
|
+
include: mergedOptions.sourceFolders,
|
|
304
|
+
use: [require.resolve('style-loader'), {
|
|
305
|
+
loader: require.resolve('css-loader'),
|
|
306
|
+
options: {
|
|
307
|
+
modules: {
|
|
308
|
+
mode: 'local',
|
|
309
|
+
localIdentName: '[name]__[local]___[hash:base64:5]',
|
|
310
|
+
localIdentHashSalt: 'ct'
|
|
311
|
+
},
|
|
312
|
+
importLoaders: 1
|
|
313
|
+
}
|
|
314
|
+
}, {
|
|
315
|
+
loader: require.resolve('postcss-loader'),
|
|
316
|
+
options: {
|
|
317
|
+
postcssOptions: createPostcssConfig.createPostcssConfig(mergedOptions.postcssOptions)
|
|
318
|
+
}
|
|
319
|
+
}]
|
|
320
|
+
}, {
|
|
321
|
+
test: function testForNormalCssFiles(fileName) {
|
|
322
|
+
return (// Use this only for plain CSS.
|
|
323
|
+
// For css-modules, see loader above.
|
|
324
|
+
_endsWithInstanceProperty__default["default"](fileName).call(fileName, '.css') && !(_endsWithInstanceProperty__default["default"](fileName).call(fileName, '.mod.css') || _endsWithInstanceProperty__default["default"](fileName).call(fileName, '.module.css'))
|
|
325
|
+
);
|
|
326
|
+
},
|
|
327
|
+
// "postcss" loader applies autoprefixer to our CSS.
|
|
328
|
+
// "css" loader resolves paths in CSS and adds assets as dependencies.
|
|
329
|
+
// "style" loader turns CSS into JS modules that inject <style> tags.
|
|
330
|
+
oneOf: [{
|
|
331
|
+
// Use "postcss" for all the included source folders.
|
|
332
|
+
include: mergedOptions.sourceFolders,
|
|
333
|
+
use: [require.resolve('style-loader'), {
|
|
334
|
+
loader: require.resolve('css-loader'),
|
|
335
|
+
options: {
|
|
336
|
+
modules: {
|
|
337
|
+
mode: 'icss'
|
|
338
|
+
},
|
|
339
|
+
importLoaders: 1
|
|
340
|
+
}
|
|
341
|
+
}, {
|
|
342
|
+
loader: require.resolve('postcss-loader'),
|
|
343
|
+
options: {
|
|
344
|
+
postcssOptions: createPostcssConfig.createPostcssConfig(mergedOptions.postcssOptions)
|
|
345
|
+
}
|
|
346
|
+
}]
|
|
347
|
+
}, {
|
|
348
|
+
// For all other vendor CSS, do not use "postcss" loader.
|
|
349
|
+
include: /node_modules/,
|
|
350
|
+
use: [require.resolve('style-loader'), {
|
|
351
|
+
loader: require.resolve('css-loader'),
|
|
352
|
+
options: {
|
|
353
|
+
modules: {
|
|
354
|
+
mode: 'icss'
|
|
355
|
+
},
|
|
356
|
+
importLoaders: 1
|
|
357
|
+
}
|
|
358
|
+
}]
|
|
359
|
+
}]
|
|
360
|
+
}, // Fix for react-intl
|
|
361
|
+
// https://github.com/formatjs/formatjs/issues/143#issuecomment-518774786
|
|
362
|
+
{
|
|
363
|
+
test: /\.mjs$/,
|
|
364
|
+
type: 'javascript/auto',
|
|
365
|
+
resolve: {
|
|
366
|
+
// https://webpack.js.org/configuration/module/#resolvefullyspecified
|
|
367
|
+
fullySpecified: false
|
|
368
|
+
}
|
|
369
|
+
}, // Process JS with Babel.
|
|
370
|
+
{
|
|
371
|
+
test: /\.(js|mjs|cjs|jsx|ts|tsx)$/,
|
|
372
|
+
use: [// This loader parallelizes code compilation, it is optional but
|
|
373
|
+
// improves compile time on larger projects
|
|
374
|
+
{
|
|
375
|
+
loader: require.resolve('thread-loader'),
|
|
376
|
+
options: {
|
|
377
|
+
poolTimeout: Infinity // keep workers alive for more effective watch mode
|
|
378
|
+
|
|
379
|
+
}
|
|
380
|
+
}, {
|
|
381
|
+
loader: require.resolve('babel-loader'),
|
|
382
|
+
options: {
|
|
383
|
+
babelrc: false,
|
|
384
|
+
configFile: false,
|
|
385
|
+
compact: false,
|
|
386
|
+
presets: [[require.resolve('@commercetools-frontend/babel-preset-mc-app'), {
|
|
387
|
+
runtime: hasJsxRuntime.hasJsxRuntime() ? 'automatic' : 'classic'
|
|
388
|
+
}]],
|
|
389
|
+
plugins: _filterInstanceProperty__default["default"](_context4 = [hasReactRefresh && require.resolve('react-refresh/babel')]).call(_context4, Boolean),
|
|
390
|
+
// This is a feature of `babel-loader` for webpack (not Babel itself).
|
|
391
|
+
// It enables caching results in ./node_modules/.cache/babel-loader/
|
|
392
|
+
// directory for faster rebuilds.
|
|
393
|
+
cacheDirectory: true,
|
|
394
|
+
highlightCode: true
|
|
395
|
+
}
|
|
396
|
+
}],
|
|
397
|
+
include: _concatInstanceProperty__default["default"](_context5 = mergedOptions.sourceFolders).call(_context5, vendorsToTranspile.vendorsToTranspile),
|
|
398
|
+
// Disable require.ensure as it's not a standard language feature.
|
|
399
|
+
parser: {
|
|
400
|
+
requireEnsure: false
|
|
401
|
+
}
|
|
402
|
+
}, // Allow to import `*.graphql` SDL files.
|
|
403
|
+
{
|
|
404
|
+
test: /\.graphql$/,
|
|
405
|
+
include: mergedOptions.sourceFolders,
|
|
406
|
+
use: [require.resolve('graphql-tag/loader')]
|
|
407
|
+
}]
|
|
408
|
+
},
|
|
409
|
+
// Turn off performance processing because we utilize
|
|
410
|
+
// our own hints via the FileSizeReporter
|
|
411
|
+
performance: false,
|
|
412
|
+
// For dev server
|
|
413
|
+
infrastructureLogging: {
|
|
414
|
+
level: 'none'
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
exports.createWebpackConfigForDevelopment = createWebpackConfigForDevelopment;
|