mirror of
https://github.com/zebrajr/react.git
synced 2025-12-06 12:20:20 +01:00
[rollup] Add support for running prebuild commands (#32592)
Extracting portions of #32416 for easier review. Adds a new `prebuild` option to allow for a prebuild command to be run prior to building the bundle. Co-authored-by: michael faith <michaelfaith@users.noreply.github.com> --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/react/pull/32592). * __->__ #32592 * #32591 * #32590 * #32589 * #32588 --------- Co-authored-by: michael faith <michaelfaith@users.noreply.github.com>
This commit is contained in:
parent
8646349aeb
commit
a8ab2bcb62
|
|
@ -12,6 +12,7 @@ const stripBanner = require('rollup-plugin-strip-banner');
|
||||||
const chalk = require('chalk');
|
const chalk = require('chalk');
|
||||||
const resolve = require('@rollup/plugin-node-resolve').nodeResolve;
|
const resolve = require('@rollup/plugin-node-resolve').nodeResolve;
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
const childProcess = require('child_process');
|
||||||
const argv = require('minimist')(process.argv.slice(2));
|
const argv = require('minimist')(process.argv.slice(2));
|
||||||
const Modules = require('./modules');
|
const Modules = require('./modules');
|
||||||
const Bundles = require('./bundles');
|
const Bundles = require('./bundles');
|
||||||
|
|
@ -812,6 +813,11 @@ function handleRollupError(error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function runShellCommand(command) {
|
||||||
|
console.log(chalk.dim('Running: ') + chalk.cyan(command));
|
||||||
|
childProcess.execSync(command, {stdio: 'inherit', shell: true});
|
||||||
|
}
|
||||||
|
|
||||||
async function buildEverything() {
|
async function buildEverything() {
|
||||||
if (!argv['unsafe-partial']) {
|
if (!argv['unsafe-partial']) {
|
||||||
await asyncRimRaf('build');
|
await asyncRimRaf('build');
|
||||||
|
|
@ -859,6 +865,9 @@ async function buildEverything() {
|
||||||
|
|
||||||
// eslint-disable-next-line no-for-of-loops/no-for-of-loops
|
// eslint-disable-next-line no-for-of-loops/no-for-of-loops
|
||||||
for (const [bundle, bundleType] of bundles) {
|
for (const [bundle, bundleType] of bundles) {
|
||||||
|
if (bundle.prebuild) {
|
||||||
|
runShellCommand(bundle.prebuild);
|
||||||
|
}
|
||||||
await createBundle(bundle, bundleType);
|
await createBundle(bundle, bundleType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user