Yes. We aren't able to make automation testing.
Yes
node -v: 9.4.0npm -v: 5.6.0yarn --version (if you use Yarn): 1.3.2npm ls react-scripts (if you haven’t ejected): [email protected]Then, specify:
We would like to see unminified component's class names for our staging environment to make end-to-end automated testing. We use these names in our test cases, so we don't want to see them mangled.
Class names are mangled.

It's easy to fix by adding options to disable mangling in webpack.config.prod.js:
new webpack.optimize.UglifyJsPlugin({
// ...
mangle: {
keep_classnames: true,
keep_fnames: true
},
// ...
}),
Maybe adding the option to .env file is good way here?
[email protected] you're on the wrong repo! 😄
I believe react-scripts-ts is in sync with react-scripts. Actually, if I create app based on react-scripts I'll have exactly same problem.
/cc @wmonk
Oh, I'm sorry -- I misread this. I thought this was the development environment.
What you called "staging environment" is generated using our production build, which is always going to mangle class names in interest of file size.
Offering tunability in yarn build is a slippery slope, so I don't think we'll be exploring it.
Something which built by build server and pubished somewhere on a server. I don't ask to disable it, I would ask to give us an option to disable it.
@Timer @wmonk so, any update on this? I don't want to eject an app just because of one line in webpack config :-)
I don't believe this is a good option to add. Regarding you exact issue I suggest you use data tags to identify your components. Class names - even before minification like this existed - were inherently bad for identification due to the unfixed and subjective nature of naming. Using something like data-test-id="header-button" is preferable as it shows intent, and is unlikely to be refactored away.
Just reread your original post and not sure my comment solves your issue? What are you using the Component Class names for?
We have our own component hierarchy. The idea was to use component's class name to find it in tree. As for me data attributes looks like a hack.
Why do you think it isn't a good option to add? I believe each user of CRA should be able decide about resulting bundle shape.
@Timer @wmonk It seems the issue won't be fixed?
No, sorry. Giving these sort of configuration options are outside of our values.
If you feel strongly about this, you'll need to eject.
One use case where this kind of functionality would be helpful in production is for componentStack error handling in componentDidCatch when sourcemaps are not available client side (e.g. when using Sentry for server side sourcemapping).
As it is, the componentStack is unusable in such cases. @Timer
One thing you can do is to explicitly give some components displayName. Minifier won't remove it.
function Stuff() {}
Stuff.displayName = 'Stuff'
Giving it to every component is overkill and will bloat your bundle. But if you strategically pick a few dozen components (depending on your product size) I think it will give you a good balance.
Most helpful comment
One thing you can do is to explicitly give some components
displayName. Minifier won't remove it.Giving it to every component is overkill and will bloat your bundle. But if you strategically pick a few dozen components (depending on your product size) I think it will give you a good balance.