'react-scripts build an unminified version
How do can you get the "build": "react-scripts build" in a package.json to build an unminified version of the code.
I have looked at the answers in this post but they are all too complicated:
How to build a production version of React without minification?
I can see in node_modules/react-scripts/config/webpack.config.js that the build is set by this code:
const isEnvDevelopment = webpackEnv === 'development'
const isEnvProduction = webpackEnv === 'production';
if I added a build-dev in the package.json, how would I make webpackEnv 'development'?
Solution 1:[1]
Hack valid (at least used) for React 17.0.2 & Co.
Open the file
node_modules/react-scripts/scripts/build.js
Locate the lines saying
process.env.BABEL_ENV = 'production';
process.env.NODE_ENV = 'production';
Change to
process.env.BABEL_ENV = 'development';
process.env.NODE_ENV = 'development';
Locate the line saying
const config = configFactory('production');
Change to
const config = configFactory('development');
If the error is disturbing your env, then comment out
printFileSizesAfterBuild(
stats,
previousFileSizes,
paths.appBuild,
WARN_AFTER_BUNDLE_GZIP_SIZE,
WARN_AFTER_CHUNK_GZIP_SIZE
);
to
/*
printFileSizesAfterBuild(
stats,
previousFileSizes,
paths.appBuild,
WARN_AFTER_BUNDLE_GZIP_SIZE,
WARN_AFTER_CHUNK_GZIP_SIZE
);
*/
Then (adjust the file copying to your local environment):
npm run build
scp -r build/* dist/* target:/webroot
Good luck.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | user18614706 |
