How can I remove some developer component from the production build without ejecting? #12416
-
Hi all, In my react app, I have some pages that I enable in the router with an environmental variable. Those pages have components that are only used for debugging by developers. When I create a production build, I'd really like it if I could remove those components from the build so they aren't included in the codebase. Is that possible without ejecting? I was thinking I'd have to customize webpack to do this but I'm not sure. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Using source-map-explorer I found that the components I was worried about already were excluded from the production build. I was using an environment variable to exclude them from the react-router-dom Switch block, so CRA/webpack must be configured to drop any import that isn't used. |
Beta Was this translation helpful? Give feedback.
Using source-map-explorer I found that the components I was worried about already were excluded from the production build. I was using an environment variable to exclude them from the react-router-dom Switch block, so CRA/webpack must be configured to drop any import that isn't used.