Hi, I want to pass argument to rewire for webpack-bundle-analyzer, is it possible?
react-app-rewired build --bundle-report
if (env === "production") { // && arg === "--bundle-report"?
config.plugins.push(new BundleAnalyzerPlugin());
}
In the override:
const bundleReportIndex = process.argv.indexOf('--bundle-report');
if (env === 'production' && bundleReportIndex !== -1) {
config.plugins.push(new BundleAnalyzerPlugin());
}
Then when you actually do the command line: npm run build --bundle-report or yarn build --bundle-report.
If you want a script target in package.json:
"scripts": {
"build": "react-app-rewired build",
"build:bundle": "react-app-rewired build --bundle-report"
}
and then run it with npm run build:bundle or yarn build:bundle.
Thanks! 馃憤
I would use just environment variables set directly in cli or with help of .env* files, if I were you. Then you just check it with process.env.MY_VAR
Most helpful comment
In the override:
Then when you actually do the command line:
npm run build --bundle-reportoryarn build --bundle-report.If you want a script target in package.json:
and then run it with
npm run build:bundleoryarn build:bundle.