Skip to content

Conversation

svenliebig
Copy link

I added an environment variable to prevent the terser plugin from minifying js class names in the production build.

The variable is: KEEP_CLASS_NAMES - i added an example in the documentation, beneath the production-build documentation.

There is no major change, the production build will be equal to the production build before this pull request, if there is no environment variable set.

@facebook-github-bot
Copy link

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@stale
Copy link

stale bot commented Apr 23, 2019

This pull request has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

@stale stale bot added the stale label Apr 23, 2019
@svenliebig
Copy link
Author

Is there any possibility to get this merged?

@keblodev
Copy link

keblodev commented Oct 9, 2020

so why no one looked at this? not even a feedback comment?
cuz this is literally what's happening right now with my app and me forced to use libraries that use material-ui with it's well known awesome way of doing markup and styles making it impossible to override if the library does not provides any means.

this ENV variable is exactly what my projects needs right now.

@RichardSto
Copy link

RichardSto commented Dec 10, 2020

For everyone who might be searching for a solution to keep the classnames in build here is one:

NODE_ENV=production ./node_modules/.bin/react-scripts build --profile

In "node_modules/react-scripts/webpack.config.js" this affects isEnvProductionProfile in said file,

module.exports = function (webpackEnv) {
  const isEnvDevelopment = webpackEnv === 'development';
  const isEnvProduction = webpackEnv === 'production';

  // Variable used for enabling profiling in Production
  // passed into alias object. Uses a flag if passed into the build command
  const isEnvProductionProfile =
    isEnvProduction && process.argv.includes('--profile');

which will lead to

 // Added for profiling in devtools
 keep_classnames: isEnvProductionProfile,

keep_classnames being true and as the name points out, classnames will be kept.

Props for coming up this solution go to @tstec-polypoly.

Copy link
Contributor

@Timer Timer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just leaving this review since I saw it in my pending requests! Best of luck with the PR! Seems to be a GitHub bug since I no longer have rights.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants