The npm script build command cannot modify NODE_ENV
wangs1203 opened this issue · comments
Emiya_Leon commented
What's happening
The npm script build command cannot modify NODE_ENV
What should happen
"build:dev": "dotenv -e .env.development craco build" or "build:dev": "cross-env NODE_ENV=development craco build"
NODE_ENV should be development
packages/craco/src/scripts/build.ts this file
import type { BaseContext } from '@craco/types';
process.env.NODE_ENV = 'production'; // This line kills the ENV
import { findArgsFromCli } from '../lib/args';
CRACO version
7.0.0
Touqeer Hussain commented
craco sets NODE_ENV as production
to generate an optimized build. You should be able to use a custom variable here.
PS: custom variables require REACT_APP as prefix to work i.e. REACT_APP_PROJECT_ENV