@commercetools-frontend/mc-scripts 20.13.0 → 21.0.0-rc.3
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/build/bin/cli.js +39 -20
- package/build/commands/build.js +18 -10
- package/build/commands/compile-html.js +10 -52
- package/build/commands/serve.js +3 -10
- package/build/commands/start.js +3 -8
- package/build/config/create-webpack-config-for-development.js +9 -3
- package/build/config/create-webpack-config-for-production.js +11 -12
- package/build/config/paths.js +3 -4
- package/package.json +22 -20
package/build/bin/cli.js
CHANGED
|
@@ -22,7 +22,8 @@ const spawn = require('react-dev-utils/crossSpawn');
|
|
|
22
22
|
const flags = mri(process.argv.slice(2), {
|
|
23
23
|
alias: {
|
|
24
24
|
help: ['h']
|
|
25
|
-
}
|
|
25
|
+
},
|
|
26
|
+
boolean: ['build-only']
|
|
26
27
|
});
|
|
27
28
|
const commands = flags._;
|
|
28
29
|
|
|
@@ -30,22 +31,25 @@ if (commands.length === 0 || flags.help && commands.length === 0) {
|
|
|
30
31
|
console.log(`
|
|
31
32
|
Usage: mc-scripts [global-options] [command] [options]
|
|
32
33
|
|
|
34
|
+
https://docs.commercetools.com/custom-applications/api-reference/cli.
|
|
35
|
+
|
|
33
36
|
Global options:
|
|
34
37
|
|
|
35
|
-
--env <path>
|
|
38
|
+
--env <path> (optional) Parses the file path as a dotenv file and adds the variables to the environment. Multiple flags are allowed.
|
|
36
39
|
|
|
37
40
|
Commands:
|
|
38
41
|
|
|
39
|
-
build
|
|
42
|
+
build Bundles the application in production mode. Outputs a "public" folder.
|
|
43
|
+
--build-only (optional) If defined, the command only creates the production bundles without compiling the "index.html".
|
|
40
44
|
|
|
41
|
-
compile-html
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
--inline-csp (optional) If defined, the CSP config is inlined in the HTML head as a meta tag. This might be useful to keep using a static config for a hosting provider without the dynamically generated Content-Security-Policy header.
|
|
45
|
+
compile-html Compiles "index.html.template" file into a "index.html" with all the required runtime configuration. Additionally, the security headers are also compiled and printed to stdout, unless you use a "transformer".
|
|
46
|
+
--transformer <path> (optional) The path to a JS module that can be used to generate a configuration for a specific cloud provider (e.g. Vercel, Netlify).
|
|
47
|
+
--print-security-headers (optional) The path to a JS module that can be used to generate a configuration for a specific cloud provider (e.g. Vercel, Netlify).
|
|
45
48
|
|
|
46
|
-
start
|
|
49
|
+
start Starts the application in development mode using Webpack Dev Server.
|
|
50
|
+
|
|
51
|
+
serve Serves previously built and compiled application from the "public" folder.
|
|
47
52
|
|
|
48
|
-
serve Serves previously built and compiled application from the "public" folder.
|
|
49
53
|
`);
|
|
50
54
|
process.exit(0);
|
|
51
55
|
}
|
|
@@ -62,7 +66,15 @@ const applicationDirectory = fs.realpathSync(process.cwd());
|
|
|
62
66
|
// Do this as the first thing so that any code reading it knows the right env.
|
|
63
67
|
process.env.BABEL_ENV = 'production';
|
|
64
68
|
process.env.NODE_ENV = 'production';
|
|
65
|
-
|
|
69
|
+
const shouldAlsoCompile = !flags['build-only'];
|
|
70
|
+
proxyCommand(command, {
|
|
71
|
+
noExit: shouldAlsoCompile
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
if (shouldAlsoCompile) {
|
|
75
|
+
proxyCommand('compile-html');
|
|
76
|
+
}
|
|
77
|
+
|
|
66
78
|
break;
|
|
67
79
|
}
|
|
68
80
|
|
|
@@ -70,7 +82,7 @@ const applicationDirectory = fs.realpathSync(process.cwd());
|
|
|
70
82
|
{
|
|
71
83
|
// Do this as the first thing so that any code reading it knows the right env.
|
|
72
84
|
process.env.NODE_ENV = 'production';
|
|
73
|
-
proxyCommand();
|
|
85
|
+
proxyCommand(command);
|
|
74
86
|
break;
|
|
75
87
|
}
|
|
76
88
|
|
|
@@ -79,8 +91,8 @@ const applicationDirectory = fs.realpathSync(process.cwd());
|
|
|
79
91
|
// Do this as the first thing so that any code reading it knows the right env.
|
|
80
92
|
process.env.NODE_ENV = 'production'; // Get specific flag for this command.
|
|
81
93
|
|
|
82
|
-
const commandArgs = getArgsForCommand(['transformer'
|
|
83
|
-
proxyCommand({
|
|
94
|
+
const commandArgs = getArgsForCommand(['transformer']);
|
|
95
|
+
proxyCommand(command, {
|
|
84
96
|
commandArgs
|
|
85
97
|
});
|
|
86
98
|
break;
|
|
@@ -91,7 +103,7 @@ const applicationDirectory = fs.realpathSync(process.cwd());
|
|
|
91
103
|
// Do this as the first thing so that any code reading it knows the right env.
|
|
92
104
|
process.env.BABEL_ENV = 'development';
|
|
93
105
|
process.env.NODE_ENV = 'development';
|
|
94
|
-
proxyCommand();
|
|
106
|
+
proxyCommand(command);
|
|
95
107
|
break;
|
|
96
108
|
}
|
|
97
109
|
|
|
@@ -117,14 +129,15 @@ function getArgsForCommand(allowedFlags = []) {
|
|
|
117
129
|
}, []);
|
|
118
130
|
}
|
|
119
131
|
|
|
120
|
-
function proxyCommand({
|
|
121
|
-
commandArgs
|
|
132
|
+
function proxyCommand(fileName, {
|
|
133
|
+
commandArgs,
|
|
134
|
+
noExit
|
|
122
135
|
} = {}) {
|
|
123
136
|
// Load dotenv files into the process environment.
|
|
124
137
|
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
125
138
|
loadDotEnvFiles(flags); // Spawn the actual command.
|
|
126
139
|
|
|
127
|
-
const result = spawn.sync('node', [require.resolve(`../commands/${
|
|
140
|
+
const result = spawn.sync('node', [require.resolve(`../commands/${fileName}`)].concat(commandArgs), {
|
|
128
141
|
stdio: 'inherit'
|
|
129
142
|
}); // Handle exit signals.
|
|
130
143
|
|
|
@@ -132,13 +145,13 @@ function proxyCommand({
|
|
|
132
145
|
switch (result.signal) {
|
|
133
146
|
case 'SIGKILL':
|
|
134
147
|
{
|
|
135
|
-
console.log(`The command ${
|
|
148
|
+
console.log(`The command ${fileName} failed because the process exited too early. This probably means the system ran out of memory or someone called "kill -9" on the process.`);
|
|
136
149
|
break;
|
|
137
150
|
}
|
|
138
151
|
|
|
139
152
|
case 'SIGTERM':
|
|
140
153
|
{
|
|
141
|
-
console.log(`The command ${
|
|
154
|
+
console.log(`The command ${fileName} failed because the process exited too early. Someone might have called "kill" or "killall", or the system could be shutting down.`);
|
|
142
155
|
break;
|
|
143
156
|
}
|
|
144
157
|
|
|
@@ -149,7 +162,13 @@ function proxyCommand({
|
|
|
149
162
|
process.exit(1);
|
|
150
163
|
}
|
|
151
164
|
|
|
152
|
-
|
|
165
|
+
if (result.status > 0) {
|
|
166
|
+
process.exit(result.status);
|
|
167
|
+
} else {
|
|
168
|
+
if (!noExit) {
|
|
169
|
+
process.exit(result.status);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
153
172
|
} // Load dotenv files into the process environment.
|
|
154
173
|
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
155
174
|
// Inspired also by https://create-react-app.dev/docs/adding-custom-environment-variables/#what-other-env-files-can-be-used
|
package/build/commands/build.js
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
// NOTE: `react-dev-utils` does not currently fully support Webpack v5.
|
|
5
5
|
// Most of the imports work, however we might bump into some edge cases.
|
|
6
6
|
// In any case, once they release a compatible version, we should't have problems.
|
|
7
|
+
const path = require('path');
|
|
8
|
+
|
|
7
9
|
const fs = require('fs-extra');
|
|
8
10
|
|
|
9
11
|
const webpack = require('webpack');
|
|
@@ -18,6 +20,10 @@ const FileSizeReporter = require('react-dev-utils/FileSizeReporter');
|
|
|
18
20
|
|
|
19
21
|
const printBuildError = require('react-dev-utils/printBuildError');
|
|
20
22
|
|
|
23
|
+
const {
|
|
24
|
+
packageLocation: applicationStaticAssetsPath
|
|
25
|
+
} = require('@commercetools-frontend/assets');
|
|
26
|
+
|
|
21
27
|
const paths = require('../config/paths');
|
|
22
28
|
|
|
23
29
|
const createWebpackConfigForProduction = require('../config/create-webpack-config-for-production');
|
|
@@ -38,7 +44,9 @@ if (!checkRequiredFiles([])) {
|
|
|
38
44
|
measureFileSizesBeforeBuild(paths.appBuild).then(previousFileSizes => {
|
|
39
45
|
// Remove all content but keep the directory so that
|
|
40
46
|
// if you're in it, you don't end up in Trash
|
|
41
|
-
fs.emptyDirSync(paths.appBuild); //
|
|
47
|
+
fs.emptyDirSync(paths.appBuild); // Copy default files
|
|
48
|
+
|
|
49
|
+
copyDefaultFiles(); // Start the webpack build
|
|
42
50
|
|
|
43
51
|
return build(previousFileSizes);
|
|
44
52
|
}).then(({
|
|
@@ -94,17 +102,11 @@ function build(previousFileSizes) {
|
|
|
94
102
|
warnings: []
|
|
95
103
|
});
|
|
96
104
|
} else {
|
|
97
|
-
|
|
98
|
-
const rawMessages = stats.toJson({
|
|
105
|
+
messages = formatWebpackMessages(stats.toJson({
|
|
99
106
|
all: false,
|
|
100
107
|
warnings: true,
|
|
101
|
-
errors: true
|
|
102
|
-
|
|
103
|
-
});
|
|
104
|
-
messages = formatWebpackMessages({
|
|
105
|
-
errors: rawMessages.errors.map(e => e.message),
|
|
106
|
-
warnings: rawMessages.warnings.map(e => e.message)
|
|
107
|
-
});
|
|
108
|
+
errors: true
|
|
109
|
+
}));
|
|
108
110
|
}
|
|
109
111
|
|
|
110
112
|
if (messages.errors.length) {
|
|
@@ -129,4 +131,10 @@ function build(previousFileSizes) {
|
|
|
129
131
|
});
|
|
130
132
|
});
|
|
131
133
|
});
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function copyDefaultFiles() {
|
|
137
|
+
fs.copySync(path.join(applicationStaticAssetsPath, 'html-page'), paths.appBuild, {
|
|
138
|
+
dereference: true
|
|
139
|
+
});
|
|
132
140
|
}
|
|
@@ -3,69 +3,25 @@
|
|
|
3
3
|
/* eslint-disable no-console,global-require,import/no-dynamic-require */
|
|
4
4
|
const fs = require('fs');
|
|
5
5
|
|
|
6
|
-
const path = require('path');
|
|
7
|
-
|
|
8
|
-
const shelljs = require('shelljs');
|
|
9
|
-
|
|
10
6
|
const mri = require('mri');
|
|
11
7
|
|
|
12
|
-
const
|
|
13
|
-
packageLocation: applicationStaticAssetsPath
|
|
14
|
-
} = require('@commercetools-frontend/assets');
|
|
8
|
+
const chalk = require('react-dev-utils/chalk');
|
|
15
9
|
|
|
16
10
|
const {
|
|
17
11
|
compileHtml
|
|
18
12
|
} = require('@commercetools-frontend/mc-html-template');
|
|
19
13
|
|
|
14
|
+
const paths = require('../config/paths');
|
|
15
|
+
|
|
20
16
|
const flags = mri(process.argv.slice(2), {
|
|
21
|
-
boolean: ['
|
|
17
|
+
boolean: ['print-security-headers']
|
|
22
18
|
});
|
|
23
19
|
const appDirectory = fs.realpathSync(process.cwd());
|
|
24
20
|
|
|
25
|
-
const resolveApp = relativePath => path.resolve(appDirectory, relativePath);
|
|
26
|
-
|
|
27
|
-
const publicAssetsPath = resolveApp('public');
|
|
28
|
-
const paths = {
|
|
29
|
-
publicAssetsPath,
|
|
30
|
-
// NOTE: previously, for running the prod server locally, we were copying
|
|
31
|
-
// assets into public/assets and compiling the index.html into public folder.
|
|
32
|
-
// To run the app then we would define the cdnUrl as http://localhost:3001/assets,
|
|
33
|
-
// because of the assets subfolder.
|
|
34
|
-
// However, on the webpack-dev-server, the index.html and the bundles are
|
|
35
|
-
// served from the same folder. It's really complicated to get the config right
|
|
36
|
-
// and eventually it's not worth the effort as it just feels like a bloody workaround.
|
|
37
|
-
// Therefore, we do it a bit different now: keep the webpack-dev-server
|
|
38
|
-
// config as is and adjust the mc-script to serve the files the same way.
|
|
39
|
-
// Remember that for normal production usage, assets are served from a CDN.
|
|
40
|
-
// So now we have a flat public folder instead of an assets subfolder.
|
|
41
|
-
// Which means that the 3 static files (favicon, google**.html, robots.txt)
|
|
42
|
-
// need to be put somewhere else (public-assets) and copy into the public
|
|
43
|
-
// folder when the server starts.
|
|
44
|
-
publicAssetsFolderPath: path.join(applicationStaticAssetsPath, 'html-page/*'),
|
|
45
|
-
indexHtmlTemplatePath: path.join(publicAssetsPath, 'index.html.template'),
|
|
46
|
-
indexHtmlPath: path.join(publicAssetsPath, 'index.html')
|
|
47
|
-
};
|
|
48
|
-
shelljs.rm('-rf', publicAssetsPath);
|
|
49
|
-
shelljs.mkdir('-p', publicAssetsPath);
|
|
50
|
-
shelljs.cp('-R', paths.publicAssetsFolderPath, publicAssetsPath); // Resolve the absolute path of the caller location. This is necessary
|
|
51
|
-
// to point to files within that folder.
|
|
52
|
-
|
|
53
|
-
const assetsFrom = resolveApp('dist/assets'); // Make sure that the `dist/assets` folder is available.
|
|
54
|
-
|
|
55
|
-
try {
|
|
56
|
-
fs.accessSync(assetsFrom, fs.F_OK);
|
|
57
|
-
} catch (error) {
|
|
58
|
-
throw new Error('Could not find "dist/assets" folder. Did you run `mc-scripts build` first?');
|
|
59
|
-
} // Copy the `dist/assets` folder into the `public` folder.
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
shelljs.cp('-R', path.join(assetsFrom, '/*'), publicAssetsPath);
|
|
63
|
-
|
|
64
21
|
const generateStatic = async () => {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
fs.writeFileSync(paths.indexHtmlPath, compiled.indexHtmlContent, {
|
|
22
|
+
console.log('Compiling index.html...');
|
|
23
|
+
const compiled = await compileHtml(paths.appIndexHtmlTemplate);
|
|
24
|
+
fs.writeFileSync(paths.appIndexHtml, compiled.indexHtmlContent, {
|
|
69
25
|
encoding: 'utf8'
|
|
70
26
|
});
|
|
71
27
|
|
|
@@ -81,9 +37,11 @@ const generateStatic = async () => {
|
|
|
81
37
|
} catch (error) {
|
|
82
38
|
throw new Error(`Could not load transformer module "${flags.transformer}"\n${error.stack}`);
|
|
83
39
|
}
|
|
84
|
-
} else {
|
|
40
|
+
} else if (flags['print-security-headers']) {
|
|
85
41
|
console.log(JSON.stringify(compiled.headers));
|
|
86
42
|
}
|
|
43
|
+
|
|
44
|
+
console.log(chalk.green('Compiled successfully.\n'));
|
|
87
45
|
};
|
|
88
46
|
|
|
89
47
|
generateStatic().catch(error => {
|
package/build/commands/serve.js
CHANGED
|
@@ -1,25 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
/* eslint-disable no-console,global-require,import/no-dynamic-require */
|
|
4
|
-
const fs = require('fs');
|
|
5
|
-
|
|
6
|
-
const path = require('path');
|
|
7
|
-
|
|
8
4
|
const http = require('http');
|
|
9
5
|
|
|
10
6
|
const serveHandler = require('serve-handler');
|
|
11
7
|
|
|
12
|
-
const
|
|
13
|
-
const appDirectory = fs.realpathSync(process.cwd());
|
|
8
|
+
const paths = require('../config/paths');
|
|
14
9
|
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
const publicAssetsPath = resolveApp('public');
|
|
10
|
+
const port = 3001;
|
|
18
11
|
const server = http.createServer((request, response) => {
|
|
19
12
|
// You pass two more arguments for config and middleware
|
|
20
13
|
// More details here: https://github.com/vercel/serve-handler#options
|
|
21
14
|
return serveHandler(request, response, {
|
|
22
|
-
public:
|
|
15
|
+
public: paths.appBuild,
|
|
23
16
|
rewrites: [{
|
|
24
17
|
source: '/favicon*',
|
|
25
18
|
destination: '/favicon.png'
|
package/build/commands/start.js
CHANGED
|
@@ -73,18 +73,13 @@ choosePort(HOST, DEFAULT_PORT).then(port => {
|
|
|
73
73
|
|
|
74
74
|
const serverConfig = createDevServerConfig({
|
|
75
75
|
allowedHost: urls.localUrlForBrowser,
|
|
76
|
-
contentBase: paths.
|
|
76
|
+
contentBase: paths.appBuild,
|
|
77
77
|
port,
|
|
78
78
|
publicPath: config.output.publicPath
|
|
79
79
|
});
|
|
80
|
-
const devServer = new WebpackDevServer(
|
|
81
|
-
|
|
82
|
-
devServer.listen(port, HOST, err => {
|
|
83
|
-
if (err) {
|
|
84
|
-
console.log(err);
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
80
|
+
const devServer = new WebpackDevServer(serverConfig, compiler); // Launch WebpackDevServer.
|
|
87
81
|
|
|
82
|
+
devServer.startCallback(() => {
|
|
88
83
|
if (isInteractive) {
|
|
89
84
|
clearConsole();
|
|
90
85
|
}
|
|
@@ -30,7 +30,6 @@ const defaultToggleFlags = {
|
|
|
30
30
|
disableCoreJs: false
|
|
31
31
|
};
|
|
32
32
|
const defaultOptions = {
|
|
33
|
-
distPath: paths.distPath,
|
|
34
33
|
entryPoint: paths.entryPoint,
|
|
35
34
|
sourceFolders: paths.sourceFolders,
|
|
36
35
|
postcssOptions: {},
|
|
@@ -50,7 +49,6 @@ const reactRefreshOverlayEntry = require.resolve('react-dev-utils/refreshOverlay
|
|
|
50
49
|
* "entry point".
|
|
51
50
|
*
|
|
52
51
|
* @param {Object} options - Options to configure the Webpack config
|
|
53
|
-
* @param {string} options.distPath - The absolute path to the `dist` folder where Webpack should output the assets.
|
|
54
52
|
* @param {string} options.entryPoint - The absolute path to the application entry point file.
|
|
55
53
|
* @param {string[]} options.sourceFolders[] - A list of folders where Webpack should look for source files.
|
|
56
54
|
* @param {Object} options.postcssOptions - Options related to Postcss plugins. See `createPostcssConfig` function.
|
|
@@ -98,7 +96,15 @@ module.exports = function createWebpackConfigForDevelopment(options = {}) {
|
|
|
98
96
|
// https://github.com/facebook/create-react-app/issues/290
|
|
99
97
|
// `web` extension prefixes have been added for better support
|
|
100
98
|
// for React Native Web.
|
|
101
|
-
extensions: ['js', 'mjs', 'cjs', 'ts', 'tsx', 'json', 'jsx'].map(ext => `.${ext}`)
|
|
99
|
+
extensions: ['js', 'mjs', 'cjs', 'ts', 'tsx', 'json', 'jsx'].map(ext => `.${ext}`),
|
|
100
|
+
// NOTE: this is meant to be a temporary list of fallback/polyfills for certain
|
|
101
|
+
// nodejs modules. With Webpack <5 these polyfills were included by default in Webpack,
|
|
102
|
+
// however now it's not the case anymore.
|
|
103
|
+
// See also related work in CRA: https://github.com/facebook/create-react-app/pull/11764
|
|
104
|
+
fallback: {
|
|
105
|
+
url: require.resolve('url/'),
|
|
106
|
+
querystring: require.resolve('querystring-es3')
|
|
107
|
+
}
|
|
102
108
|
},
|
|
103
109
|
entry: {
|
|
104
110
|
app: [require.resolve('./application-runtime'), !mergedOptions.toggleFlags.disableCoreJs && require.resolve('core-js/stable'), // When using the experimental `react-refresh` integration,
|
|
@@ -13,8 +13,7 @@ const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
|
|
|
13
13
|
|
|
14
14
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
15
15
|
|
|
16
|
-
const MomentLocalesPlugin = require('moment-locales-webpack-plugin');
|
|
17
|
-
|
|
16
|
+
const MomentLocalesPlugin = require('moment-locales-webpack-plugin');
|
|
18
17
|
|
|
19
18
|
const TerserPlugin = require('terser-webpack-plugin');
|
|
20
19
|
|
|
@@ -46,7 +45,6 @@ const defaultToggleFlags = {
|
|
|
46
45
|
disableCoreJs: false
|
|
47
46
|
};
|
|
48
47
|
const defaultOptions = {
|
|
49
|
-
distPath: paths.distPath,
|
|
50
48
|
entryPoint: paths.entryPoint,
|
|
51
49
|
sourceFolders: paths.sourceFolders,
|
|
52
50
|
postcssOptions: {},
|
|
@@ -59,7 +57,6 @@ const defaultOptions = {
|
|
|
59
57
|
* "entry point".
|
|
60
58
|
*
|
|
61
59
|
* @param {Object} options - Options to configure the Webpack config
|
|
62
|
-
* @param {string} options.distPath - The absolute path to the `dist` folder where Webpack should output the assets.
|
|
63
60
|
* @param {string} options.entryPoint - The absolute path to the application entry point file.
|
|
64
61
|
* @param {string[]} options.sourceFolders[] - A list of folders where Webpack should look for source files.
|
|
65
62
|
* @param {Object} options.postcssOptions - Options related to Postcss plugins. See `createPostcssConfig` function.
|
|
@@ -141,7 +138,14 @@ module.exports = function createWebpackConfigForProduction(options = {}) {
|
|
|
141
138
|
// https://github.com/facebook/create-react-app/issues/290
|
|
142
139
|
// `web` extension prefixes have been added for better support
|
|
143
140
|
// for React Native Web.
|
|
144
|
-
extensions: ['js', 'mjs', 'cjs', 'ts', 'tsx', 'json', 'jsx'].map(ext => `.${ext}`)
|
|
141
|
+
extensions: ['js', 'mjs', 'cjs', 'ts', 'tsx', 'json', 'jsx'].map(ext => `.${ext}`),
|
|
142
|
+
// NOTE: this is meant to be a temporary list of fallback/polyfills for certain
|
|
143
|
+
// nodejs modules. With Webpack <5 these polyfills were included by default in Webpack,
|
|
144
|
+
// however now it's not the case anymore.
|
|
145
|
+
// See also related work in CRA: https://github.com/facebook/create-react-app/pull/11764
|
|
146
|
+
fallback: {
|
|
147
|
+
querystring: require.resolve('querystring-es3')
|
|
148
|
+
}
|
|
145
149
|
},
|
|
146
150
|
// In production, we only want to load the polyfills and the app code.
|
|
147
151
|
entry: {
|
|
@@ -158,12 +162,7 @@ module.exports = function createWebpackConfigForProduction(options = {}) {
|
|
|
158
162
|
// Will be injected on runtime. See `packages/application-shell/src/public-path.js`
|
|
159
163
|
publicPath: ''
|
|
160
164
|
},
|
|
161
|
-
plugins: [//
|
|
162
|
-
// dangerouslyAllowCleanPatternsOutsideProject: true,
|
|
163
|
-
// dry: true,
|
|
164
|
-
// cleanOnceBeforeBuildPatterns: [mergedOptions.distPath],
|
|
165
|
-
// }),
|
|
166
|
-
// Allows to "assign" custom options to the `webpack` object.
|
|
165
|
+
plugins: [// Allows to "assign" custom options to the `webpack` object.
|
|
167
166
|
// At the moment, this is used to share some props with `postcss.config`.
|
|
168
167
|
new webpack.LoaderOptionsPlugin({
|
|
169
168
|
options: {
|
|
@@ -186,7 +185,7 @@ module.exports = function createWebpackConfigForProduction(options = {}) {
|
|
|
186
185
|
// This is necessary to programmatically refer to the correct bundle path
|
|
187
186
|
// in the `index.html`.
|
|
188
187
|
new FinalStatsWriterPlugin({
|
|
189
|
-
outputPath:
|
|
188
|
+
outputPath: paths.appBuild,
|
|
190
189
|
includeFields: ['entrypoints', 'assets', 'publicPath', 'time']
|
|
191
190
|
}), mergedOptions.toggleFlags.generateIndexHtml && new HtmlWebpackPlugin({
|
|
192
191
|
inject: false,
|
package/build/config/paths.js
CHANGED
|
@@ -26,13 +26,12 @@ const resolveModule = (resolveFn, filePath) => {
|
|
|
26
26
|
|
|
27
27
|
const paths = {
|
|
28
28
|
appPackageJson: resolveApp('package.json'),
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
appIndexHtml: resolveApp('
|
|
29
|
+
appBuild: resolveApp('public'),
|
|
30
|
+
appIndexHtmlTemplate: resolveApp('public/index.html.template'),
|
|
31
|
+
appIndexHtml: resolveApp('public/index.html'),
|
|
32
32
|
appWebpackConfig: resolveModule(resolveApp, `webpack.config.${process.env.NODE_ENV === 'production' ? 'prod' : 'dev'}`),
|
|
33
33
|
yarnLockFile: resolveApp('yarn.lock'),
|
|
34
34
|
appRoot: resolveApp('.'),
|
|
35
|
-
distPath: resolveApp('dist'),
|
|
36
35
|
entryPoint: resolveModule(resolveApp, 'src/index'),
|
|
37
36
|
sourceFolders: [resolveApp('src')]
|
|
38
37
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools-frontend/mc-scripts",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "21.0.0-rc.3",
|
|
4
4
|
"description": "Configuration and scripts for developing a MC application",
|
|
5
5
|
"bugs": "https://github.com/commercetools/merchant-center-application-kit/issues",
|
|
6
6
|
"repository": {
|
|
@@ -26,21 +26,21 @@
|
|
|
26
26
|
"build:bundles:watch": "yarn build -w"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@babel/runtime": "7.16.
|
|
30
|
-
"@babel/runtime-corejs3": "7.16.
|
|
31
|
-
"@commercetools-frontend/application-config": "
|
|
32
|
-
"@commercetools-frontend/assets": "
|
|
33
|
-
"@commercetools-frontend/babel-preset-mc-app": "
|
|
34
|
-
"@commercetools-frontend/mc-dev-authentication": "
|
|
35
|
-
"@commercetools-frontend/mc-html-template": "
|
|
36
|
-
"@pmmmwh/react-refresh-webpack-plugin": "0.5.
|
|
29
|
+
"@babel/runtime": "^7.16.7",
|
|
30
|
+
"@babel/runtime-corejs3": "^7.16.8",
|
|
31
|
+
"@commercetools-frontend/application-config": "21.0.0-rc.1",
|
|
32
|
+
"@commercetools-frontend/assets": "21.0.0-rc.1",
|
|
33
|
+
"@commercetools-frontend/babel-preset-mc-app": "21.0.0-rc.1",
|
|
34
|
+
"@commercetools-frontend/mc-dev-authentication": "21.0.0-rc.1",
|
|
35
|
+
"@commercetools-frontend/mc-html-template": "21.0.0-rc.3",
|
|
36
|
+
"@pmmmwh/react-refresh-webpack-plugin": "0.5.4",
|
|
37
37
|
"@svgr/webpack": "6.2.0",
|
|
38
|
-
"autoprefixer": "10.4.
|
|
38
|
+
"autoprefixer": "10.4.2",
|
|
39
39
|
"babel-loader": "8.2.3",
|
|
40
40
|
"browserslist": "4.19.1",
|
|
41
|
-
"core-js": "3.20.
|
|
41
|
+
"core-js": "^3.20.3",
|
|
42
42
|
"css-loader": "5.2.7",
|
|
43
|
-
"css-minimizer-webpack-plugin": "3.
|
|
43
|
+
"css-minimizer-webpack-plugin": "3.4.1",
|
|
44
44
|
"dotenv": "10.0.0",
|
|
45
45
|
"dotenv-expand": "5.1.0",
|
|
46
46
|
"fs-extra": "10.0.0",
|
|
@@ -56,8 +56,9 @@
|
|
|
56
56
|
"postcss-custom-properties": "11.0.0",
|
|
57
57
|
"postcss-import": "14.0.2",
|
|
58
58
|
"postcss-loader": "6.2.1",
|
|
59
|
-
"postcss-reporter": "7.0.
|
|
60
|
-
"
|
|
59
|
+
"postcss-reporter": "7.0.5",
|
|
60
|
+
"querystring-es3": "^0.2.1",
|
|
61
|
+
"react-dev-utils": "12.0.0",
|
|
61
62
|
"react-refresh": "0.11.0",
|
|
62
63
|
"serve-handler": "6.1.3",
|
|
63
64
|
"shelljs": "0.8.5",
|
|
@@ -65,18 +66,19 @@
|
|
|
65
66
|
"svg-url-loader": "7.1.1",
|
|
66
67
|
"terser-webpack-plugin": "5.3.0",
|
|
67
68
|
"thread-loader": "3.0.4",
|
|
68
|
-
"
|
|
69
|
+
"url": "^0.11.0",
|
|
70
|
+
"webpack": "5.66.0",
|
|
69
71
|
"webpack-bundle-analyzer": "4.5.0",
|
|
70
|
-
"webpack-dev-server": "4.
|
|
72
|
+
"webpack-dev-server": "4.7.3",
|
|
71
73
|
"webpackbar": "5.0.2"
|
|
72
74
|
},
|
|
73
75
|
"devDependencies": {
|
|
74
|
-
"@babel/plugin-transform-runtime": "7.16.
|
|
75
|
-
"@babel/preset-env": "7.16.
|
|
76
|
+
"@babel/plugin-transform-runtime": "^7.16.10",
|
|
77
|
+
"@babel/preset-env": "^7.16.11",
|
|
76
78
|
"rimraf": "3.0.2"
|
|
77
79
|
},
|
|
78
80
|
"engines": {
|
|
79
|
-
"node": ">=
|
|
81
|
+
"node": ">=14"
|
|
80
82
|
},
|
|
81
83
|
"babel": {
|
|
82
84
|
"presets": [
|
|
@@ -84,7 +86,7 @@
|
|
|
84
86
|
"@babel/preset-env",
|
|
85
87
|
{
|
|
86
88
|
"targets": {
|
|
87
|
-
"node": "
|
|
89
|
+
"node": "14"
|
|
88
90
|
},
|
|
89
91
|
"modules": "commonjs",
|
|
90
92
|
"useBuiltIns": "usage",
|