@commercetools-frontend/mc-scripts 21.7.0 → 21.8.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 +354 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.js +7 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.prod.js +354 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.esm.js +338 -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-8582b673.esm.js +209 -0
- package/dist/build-9395925a.cjs.prod.js +224 -0
- package/dist/build-97278377.cjs.dev.js +224 -0
- package/dist/build-vite-6c987a60.cjs.dev.js +109 -0
- package/dist/build-vite-76d44332.cjs.prod.js +109 -0
- package/dist/build-vite-a9602b19.esm.js +97 -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-0c588a89.cjs.dev.js +93 -0
- package/dist/compile-html-4832f8c5.esm.js +83 -0
- package/dist/compile-html-7654b5e6.cjs.prod.js +93 -0
- package/dist/config-sync-20bc05e8.esm.js +868 -0
- package/dist/config-sync-62824317.cjs.prod.js +887 -0
- package/dist/config-sync-d52e73f6.cjs.dev.js +892 -0
- package/dist/create-postcss-config-4cbe10ab.cjs.dev.js +90 -0
- package/dist/create-postcss-config-8ea16440.cjs.prod.js +90 -0
- package/{build/config/create-postcss-config.js → dist/create-postcss-config-c1aa3525.esm.js} +27 -25
- package/{build/config/create-webpack-config-for-development.js → dist/create-webpack-config-for-development-8a8b84d6.esm.js} +92 -56
- package/dist/create-webpack-config-for-development-a5e73092.cjs.prod.js +418 -0
- package/dist/create-webpack-config-for-development-e2735e02.cjs.dev.js +418 -0
- package/dist/create-webpack-config-for-production-4e7b56c0.cjs.prod.js +468 -0
- package/{build/config/create-webpack-config-for-production.js → dist/create-webpack-config-for-production-7dc669e5.esm.js} +117 -52
- package/dist/create-webpack-config-for-production-d9bf281c.cjs.dev.js +468 -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/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 +2383 -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/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-706ccc9a.cjs.prod.js +165 -0
- package/dist/login-779552b7.cjs.dev.js +165 -0
- package/dist/login-7d94659e.esm.js +155 -0
- package/dist/package-a98de907.esm.js +133 -0
- package/dist/package-aaf61bf0.cjs.dev.js +135 -0
- package/dist/package-b5c040f3.cjs.prod.js +135 -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-2b953ab0.cjs.dev.js +209 -0
- package/dist/start-e3ccd672.cjs.prod.js +209 -0
- package/dist/start-e924bd5d.esm.js +194 -0
- package/dist/start-vite-737bacca.cjs.dev.js +149 -0
- package/dist/start-vite-b0f58ae4.cjs.prod.js +149 -0
- package/dist/start-vite-ec5d40b5.esm.js +136 -0
- package/dist/user-agent-5da1830b.cjs.dev.js +106 -0
- package/dist/user-agent-8044acd6.esm.js +94 -0
- package/dist/user-agent-d18809af.cjs.prod.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/package.json +41 -39
- 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
|
@@ -1,33 +1,99 @@
|
|
|
1
|
-
|
|
1
|
+
import _Object$keys from '@babel/runtime-corejs3/core-js-stable/object/keys';
|
|
2
|
+
import _Object$getOwnPropertySymbols from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols';
|
|
3
|
+
import _Object$getOwnPropertyDescriptor from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor';
|
|
4
|
+
import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/for-each';
|
|
5
|
+
import _Object$getOwnPropertyDescriptors from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors';
|
|
6
|
+
import _Object$defineProperties from '@babel/runtime-corejs3/core-js-stable/object/define-properties';
|
|
7
|
+
import _Object$defineProperty from '@babel/runtime-corejs3/core-js-stable/object/define-property';
|
|
8
|
+
import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
|
|
9
|
+
import _filterInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/filter';
|
|
10
|
+
import _mapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/map';
|
|
11
|
+
import _JSON$stringify from '@babel/runtime-corejs3/core-js-stable/json/stringify';
|
|
12
|
+
import _endsWithInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/ends-with';
|
|
13
|
+
import _Number$isInteger from '@babel/runtime-corejs3/core-js-stable/number/is-integer';
|
|
14
|
+
import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
|
|
15
|
+
import webpack from 'webpack';
|
|
16
|
+
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
17
|
+
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
|
|
18
|
+
import CssMinimizerPlugin from 'css-minimizer-webpack-plugin';
|
|
19
|
+
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
|
|
20
|
+
import MomentLocalesPlugin from 'moment-locales-webpack-plugin';
|
|
21
|
+
import TerserPlugin from 'terser-webpack-plugin';
|
|
22
|
+
import _classCallCheck from '@babel/runtime-corejs3/helpers/esm/classCallCheck';
|
|
23
|
+
import _createClass from '@babel/runtime-corejs3/helpers/esm/createClass';
|
|
24
|
+
import _bindInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/bind';
|
|
25
|
+
import _reduceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/reduce';
|
|
26
|
+
import _Object$assign from '@babel/runtime-corejs3/core-js-stable/object/assign';
|
|
27
|
+
import fs from 'fs';
|
|
28
|
+
import path from 'path';
|
|
29
|
+
import { p as paths } from './paths-ed23d5a1.esm.js';
|
|
30
|
+
import { v as vendorsToTranspile } from './vendors-to-transpile-68e03526.esm.js';
|
|
31
|
+
import { c as createPostcssConfig } from './create-postcss-config-c1aa3525.esm.js';
|
|
32
|
+
import { h as hasJsxRuntime } from './has-jsx-runtime-8314226e.esm.js';
|
|
2
33
|
|
|
3
|
-
|
|
4
|
-
|
|
34
|
+
var FinalStatsWriterPlugin = /*#__PURE__*/function () {
|
|
35
|
+
// Expected options:
|
|
36
|
+
// - `outputPath`
|
|
37
|
+
// - `includeFields`
|
|
38
|
+
function FinalStatsWriterPlugin(config) {
|
|
39
|
+
_classCallCheck(this, FinalStatsWriterPlugin);
|
|
5
40
|
|
|
6
|
-
|
|
41
|
+
this.config = void 0;
|
|
42
|
+
if (!config) throw new Error('Missing config options');
|
|
43
|
+
this.config = config;
|
|
44
|
+
}
|
|
7
45
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
46
|
+
_createClass(FinalStatsWriterPlugin, [{
|
|
47
|
+
key: "apply",
|
|
48
|
+
value: function apply(compiler) {
|
|
49
|
+
// This is the only hook that return the `stats` plugin
|
|
50
|
+
// with the `time` info. It also contains all the stats that
|
|
51
|
+
// we would get from the original `emit` hook.
|
|
52
|
+
// https://webpack.js.org/api/compiler-hooks/#done
|
|
53
|
+
// https://webpack.js.org/api/plugins/#plugin-types
|
|
54
|
+
if (compiler.hooks) {
|
|
55
|
+
var _context;
|
|
11
56
|
|
|
12
|
-
|
|
57
|
+
compiler.hooks.done.tap('custom-stats-writer-plugin', _bindInstanceProperty(_context = this.writeStats).call(_context, this));
|
|
58
|
+
} else {
|
|
59
|
+
var _context2;
|
|
13
60
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
61
|
+
// @ts-ignore
|
|
62
|
+
compiler.plugin('done', _bindInstanceProperty(_context2 = this.writeStats).call(_context2, this));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}, {
|
|
66
|
+
key: "writeStats",
|
|
67
|
+
value: function writeStats(stats) {
|
|
68
|
+
var finalStats = stats.toJson(); // Filter only included fields
|
|
19
69
|
|
|
20
|
-
|
|
70
|
+
if (this.config.includeFields) {
|
|
71
|
+
var _context3;
|
|
21
72
|
|
|
22
|
-
|
|
73
|
+
finalStats = _reduceInstanceProperty(_context3 = this.config.includeFields).call(_context3, function (aggregatedStats, key) {
|
|
74
|
+
return (// eslint-disable-next-line
|
|
75
|
+
_Object$assign({}, aggregatedStats, _defineProperty({}, key, finalStats[key]))
|
|
76
|
+
);
|
|
77
|
+
}, {});
|
|
78
|
+
}
|
|
23
79
|
|
|
24
|
-
|
|
80
|
+
try {
|
|
81
|
+
fs.accessSync(this.config.outputPath, fs.constants.F_OK);
|
|
82
|
+
fs.writeFileSync(path.join(this.config.outputPath, 'stats.json'), _JSON$stringify(finalStats, null, 2));
|
|
83
|
+
} catch (error) {
|
|
84
|
+
// eslint-disable-next-line no-console
|
|
85
|
+
console.warn("[FinalStatsWriterPlugin] The dist folder could not be found at ".concat(this.config.outputPath, ". Check the console for errors during the webpack compilation."));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}]);
|
|
25
89
|
|
|
26
|
-
|
|
90
|
+
return FinalStatsWriterPlugin;
|
|
91
|
+
}();
|
|
27
92
|
|
|
28
|
-
|
|
93
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
29
94
|
|
|
30
|
-
|
|
95
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context7, _context8; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context7 = ownKeys(Object(source), !0)).call(_context7, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context8 = ownKeys(Object(source))).call(_context8, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
96
|
+
var defaultToggleFlags = {
|
|
31
97
|
// Allow to disable CSS extraction in case it's not necessary (e.g. for Storybook)
|
|
32
98
|
enableExtractCss: true,
|
|
33
99
|
// Allow to disable index.html generation in case it's not necessary (e.g. for Storybook)
|
|
@@ -44,7 +110,7 @@ const defaultToggleFlags = {
|
|
|
44
110
|
// `plugin-transform-runtime`.
|
|
45
111
|
disableCoreJs: false
|
|
46
112
|
};
|
|
47
|
-
|
|
113
|
+
var defaultOptions = {
|
|
48
114
|
entryPoint: paths.entryPoint,
|
|
49
115
|
sourceFolders: paths.sourceFolders,
|
|
50
116
|
postcssOptions: {},
|
|
@@ -55,21 +121,17 @@ const defaultOptions = {
|
|
|
55
121
|
* for a MC Application in `production` mode.
|
|
56
122
|
* The function requires the file path to the related application
|
|
57
123
|
* "entry point".
|
|
58
|
-
*
|
|
59
|
-
* @param {Object} options - Options to configure the Webpack config
|
|
60
|
-
* @param {string} options.entryPoint - The absolute path to the application entry point file.
|
|
61
|
-
* @param {string[]} options.sourceFolders[] - A list of folders where Webpack should look for source files.
|
|
62
|
-
* @param {Object} options.postcssOptions - Options related to Postcss plugins. See `createPostcssConfig` function.
|
|
63
|
-
* @param {Object} options.toggleFlags - Options to enable/disable certain functionalities of the Webpack config.
|
|
64
124
|
*/
|
|
65
125
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
126
|
+
function createWebpackConfigForProduction() {
|
|
127
|
+
var _context, _context2, _context3, _context4, _context5, _context6;
|
|
128
|
+
|
|
129
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
130
|
+
|
|
131
|
+
var mergedOptions = _objectSpread(_objectSpread(_objectSpread({}, defaultOptions), options), {}, {
|
|
132
|
+
toggleFlags: _objectSpread(_objectSpread({}, defaultToggleFlags), options.toggleFlags)
|
|
133
|
+
});
|
|
134
|
+
|
|
73
135
|
return {
|
|
74
136
|
// Don't attempt to continue if there are any errors.
|
|
75
137
|
bail: true,
|
|
@@ -82,15 +144,15 @@ module.exports = function createWebpackConfigForProduction(options = {}) {
|
|
|
82
144
|
// https://medium.com/webpack/webpack-4-code-splitting-chunk-graph-and-the-splitchunks-optimization-be739a861366
|
|
83
145
|
// https://medium.com/webpack/webpack-4-mode-and-optimization-5423a6bc597a
|
|
84
146
|
optimization: {
|
|
85
|
-
minimizer: [new TerserPlugin({
|
|
147
|
+
minimizer: _filterInstanceProperty(_context = [new TerserPlugin({
|
|
86
148
|
terserOptions: {
|
|
87
149
|
parse: {
|
|
88
150
|
// we want terser to parse ecma 8 code. However, we don't want it
|
|
89
|
-
// to apply any
|
|
151
|
+
// to apply any minification steps that turns valid ecma 5 code
|
|
90
152
|
// into invalid ecma 5 code. This is why the 'compress' and 'output'
|
|
91
153
|
// sections only apply transformations that are ecma 5 safe
|
|
92
154
|
// https://github.com/facebook/create-react-app/pull/4234
|
|
93
|
-
ecma:
|
|
155
|
+
ecma: 2018
|
|
94
156
|
},
|
|
95
157
|
compress: {
|
|
96
158
|
ecma: 5,
|
|
@@ -123,7 +185,7 @@ module.exports = function createWebpackConfigForProduction(options = {}) {
|
|
|
123
185
|
// Use multi-process parallel running to improve the build speed
|
|
124
186
|
// Default number of concurrent runs: os.cpus().length - 1
|
|
125
187
|
parallel: mergedOptions.toggleFlags.parallelism
|
|
126
|
-
}), mergedOptions.toggleFlags.enableExtractCss && new CssMinimizerPlugin()].
|
|
188
|
+
}), mergedOptions.toggleFlags.enableExtractCss && new CssMinimizerPlugin()]).call(_context, Boolean),
|
|
127
189
|
// Keep the runtime chunk separated to enable long term caching
|
|
128
190
|
runtimeChunk: {
|
|
129
191
|
name: 'runtime'
|
|
@@ -138,7 +200,9 @@ module.exports = function createWebpackConfigForProduction(options = {}) {
|
|
|
138
200
|
// https://github.com/facebook/create-react-app/issues/290
|
|
139
201
|
// `web` extension prefixes have been added for better support
|
|
140
202
|
// for React Native Web.
|
|
141
|
-
extensions: ['js', 'mjs', 'cjs', 'ts', 'tsx', 'json', 'jsx'].
|
|
203
|
+
extensions: _mapInstanceProperty(_context2 = ['js', 'mjs', 'cjs', 'ts', 'tsx', 'json', 'jsx']).call(_context2, function (ext) {
|
|
204
|
+
return ".".concat(ext);
|
|
205
|
+
}),
|
|
142
206
|
// NOTE: this is meant to be a temporary list of fallback/polyfills for certain
|
|
143
207
|
// nodejs modules. With Webpack <5 these polyfills were included by default in Webpack,
|
|
144
208
|
// however now it's not the case anymore.
|
|
@@ -149,7 +213,7 @@ module.exports = function createWebpackConfigForProduction(options = {}) {
|
|
|
149
213
|
},
|
|
150
214
|
// In production, we only want to load the polyfills and the app code.
|
|
151
215
|
entry: {
|
|
152
|
-
app: [require.resolve('
|
|
216
|
+
app: _filterInstanceProperty(_context3 = [require.resolve('@commercetools-frontend/mc-scripts/application-runtime'), !mergedOptions.toggleFlags.disableCoreJs && require.resolve('core-js/stable'), mergedOptions.entryPoint]).call(_context3, Boolean)
|
|
153
217
|
},
|
|
154
218
|
output: {
|
|
155
219
|
// Generated JS file names (with nested folders).
|
|
@@ -162,7 +226,7 @@ module.exports = function createWebpackConfigForProduction(options = {}) {
|
|
|
162
226
|
// Will be injected on runtime. See `packages/application-shell/src/public-path.js`
|
|
163
227
|
publicPath: ''
|
|
164
228
|
},
|
|
165
|
-
plugins: [// Allows to "assign" custom options to the `webpack` object.
|
|
229
|
+
plugins: _filterInstanceProperty(_context4 = [// Allows to "assign" custom options to the `webpack` object.
|
|
166
230
|
// At the moment, this is used to share some props with `postcss.config`.
|
|
167
231
|
new webpack.LoaderOptionsPlugin({
|
|
168
232
|
options: {
|
|
@@ -174,7 +238,7 @@ module.exports = function createWebpackConfigForProduction(options = {}) {
|
|
|
174
238
|
new webpack.DefinePlugin({
|
|
175
239
|
__DEV__: 'false',
|
|
176
240
|
'process.env': {
|
|
177
|
-
NODE_ENV:
|
|
241
|
+
NODE_ENV: _JSON$stringify('production')
|
|
178
242
|
}
|
|
179
243
|
}), // Strip all locales except `en`, `de`
|
|
180
244
|
// (`en` is built into Moment and can't be removed)
|
|
@@ -197,11 +261,11 @@ module.exports = function createWebpackConfigForProduction(options = {}) {
|
|
|
197
261
|
chunkFilename: '[id].[name].[chunkhash].css'
|
|
198
262
|
}), process.env.ANALYZE_BUNDLE === 'true' && new BundleAnalyzerPlugin({
|
|
199
263
|
defaultSizes: 'gzip'
|
|
200
|
-
})].
|
|
264
|
+
})]).call(_context4, Boolean),
|
|
201
265
|
module: {
|
|
202
266
|
// Makes missing exports an error instead of warning.
|
|
203
267
|
strictExportPresence: true,
|
|
204
|
-
rules: [// For svg icons, we want to get them transformed into React components
|
|
268
|
+
rules: _filterInstanceProperty(_context5 = [// For svg icons, we want to get them transformed into React components
|
|
205
269
|
// when we import them.
|
|
206
270
|
{
|
|
207
271
|
test: /\.react\.svg$/,
|
|
@@ -242,7 +306,7 @@ module.exports = function createWebpackConfigForProduction(options = {}) {
|
|
|
242
306
|
test: function testForNormalSvgFiles(fileName) {
|
|
243
307
|
return (// Use this only for plain SVG.
|
|
244
308
|
// For SVG as React components, see loader above.
|
|
245
|
-
fileName.
|
|
309
|
+
_endsWithInstanceProperty(fileName).call(fileName, '.svg') && !_endsWithInstanceProperty(fileName).call(fileName, '.react.svg')
|
|
246
310
|
);
|
|
247
311
|
},
|
|
248
312
|
use: [{
|
|
@@ -281,7 +345,7 @@ module.exports = function createWebpackConfigForProduction(options = {}) {
|
|
|
281
345
|
test: function testForNormalCssFiles(fileName) {
|
|
282
346
|
return (// Use this only for plain CSS.
|
|
283
347
|
// For css-modules, see loader above.
|
|
284
|
-
fileName.
|
|
348
|
+
_endsWithInstanceProperty(fileName).call(fileName, '.css') && !(_endsWithInstanceProperty(fileName).call(fileName, '.mod.css') || _endsWithInstanceProperty(fileName).call(fileName, '.module.css'))
|
|
285
349
|
);
|
|
286
350
|
},
|
|
287
351
|
// "postcss" loader applies autoprefixer to our CSS.
|
|
@@ -334,10 +398,9 @@ module.exports = function createWebpackConfigForProduction(options = {}) {
|
|
|
334
398
|
// improves compile time on larger projects
|
|
335
399
|
{
|
|
336
400
|
loader: require.resolve('thread-loader'),
|
|
337
|
-
options: {
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
}
|
|
401
|
+
options: _objectSpread({}, _Number$isInteger(mergedOptions.toggleFlags.parallelism) ? {
|
|
402
|
+
workers: mergedOptions.toggleFlags.parallelism
|
|
403
|
+
} : {})
|
|
341
404
|
}, {
|
|
342
405
|
loader: require.resolve('babel-loader'),
|
|
343
406
|
options: {
|
|
@@ -354,7 +417,7 @@ module.exports = function createWebpackConfigForProduction(options = {}) {
|
|
|
354
417
|
highlightCode: true
|
|
355
418
|
}
|
|
356
419
|
}],
|
|
357
|
-
include: mergedOptions.sourceFolders.
|
|
420
|
+
include: _concatInstanceProperty(_context6 = mergedOptions.sourceFolders).call(_context6, vendorsToTranspile),
|
|
358
421
|
// Disable require.ensure as it's not a standard language feature.
|
|
359
422
|
parser: {
|
|
360
423
|
requireEnsure: false
|
|
@@ -365,10 +428,12 @@ module.exports = function createWebpackConfigForProduction(options = {}) {
|
|
|
365
428
|
include: mergedOptions.sourceFolders,
|
|
366
429
|
exclude: /node_modules/,
|
|
367
430
|
use: [require.resolve('graphql-tag/loader')]
|
|
368
|
-
}].
|
|
431
|
+
}]).call(_context5, Boolean)
|
|
369
432
|
},
|
|
370
433
|
// Turn off performance processing because we utilize
|
|
371
434
|
// our own hints via the FileSizeReporter
|
|
372
435
|
performance: false
|
|
373
436
|
};
|
|
374
|
-
}
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
export { createWebpackConfigForProduction as c };
|