feat(react): allow setting react preset to production when using custom BABEL_ENV (#19148)
This commit is contained in:
parent
7975950a8c
commit
dc8b408b1a
@ -3,6 +3,7 @@
|
||||
*/
|
||||
|
||||
interface NxReactBabelOptions {
|
||||
development?: boolean;
|
||||
runtime?: string;
|
||||
importSource?: string;
|
||||
useBuiltIns?: boolean | string;
|
||||
@ -51,10 +52,16 @@ module.exports = function (api: any, options: NxReactBabelOptions) {
|
||||
};
|
||||
};
|
||||
|
||||
function getReactPresetOptions({ presetOptions, env }) {
|
||||
function getReactPresetOptions({
|
||||
presetOptions,
|
||||
env,
|
||||
}: {
|
||||
env: string;
|
||||
presetOptions: NxReactBabelOptions;
|
||||
}) {
|
||||
const reactPresetOptions: Record<string, string | boolean> = {
|
||||
runtime: presetOptions.runtime ?? 'automatic',
|
||||
development: env !== 'production',
|
||||
development: presetOptions.development ?? env !== 'production',
|
||||
};
|
||||
|
||||
// JSX spread is transformed into object spread in `@babel/plugin-transform-react-jsx`
|
||||
|
||||
@ -70,7 +70,7 @@ function getBuildTargetOutputPath(options: Schema, context: ExecutorContext) {
|
||||
|
||||
let buildOptions;
|
||||
try {
|
||||
const target = parseTargetString(options.buildTarget, context.projectGraph);
|
||||
const target = parseTargetString(options.buildTarget, context);
|
||||
buildOptions = readTargetOptions(target, context);
|
||||
} catch (e) {
|
||||
throw new Error(`Invalid buildTarget: ${options.buildTarget}`);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user