Skip to content
This repository was archived by the owner on Jun 11, 2022. It is now read-only.

How to remove source maps? #59

Closed
lavrton opened this issue Jul 8, 2017 · 8 comments
Closed

How to remove source maps? #59

lavrton opened this issue Jul 8, 2017 · 8 comments

Comments

@lavrton
Copy link

lavrton commented Jul 8, 2017

Are there any ways to disable/remove them?
It will be nice if I can just set source_map_enabled: false in static.json.

@mars
Copy link
Owner

mars commented Jul 8, 2017

What's your motivation to make this change? Curious if this is a build time issue, a bandwidth concern, or something else.

Your specific suggestion would not apply here, because static.json is config for the web server, not javascript/create-react-app concerns.

Found a pertinent discussion about making such a customization through create-react-app.
As mentioned there, you may eject & modify webpack config to avoid generating source maps at all.

Otherwise, the inner & main buildpack could be forked and modified to delete that file after build. See architecture for how these pieces fit together.

@lavrton
Copy link
Author

lavrton commented Jul 8, 2017

@mars I just don't want to show full source code in production mode.

In other projects where I use create-react-app I manually remove *.map files as build step. This is suggested solution (facebook/create-react-app#2742 (comment)).

I think create-react-app-buildpack can do this too. Just need to delete *.map files.

@mars
Copy link
Owner

mars commented Jul 8, 2017

That's not a convincing reason for why I should add such a feature. You're welcome to eject or fork the buildpack to do this.

@mars mars closed this as completed Jul 8, 2017
@lavrton
Copy link
Author

lavrton commented Jul 19, 2017

I just found that create-react-app-buildpack use npm run build. So to remove sources maps I can simply update build script to:

"build": "react-scripts build && rm build/static/js/*.map",

@mars
Copy link
Owner

mars commented Jul 19, 2017

Thanks for following-up @lavrton. Glad to see the fix ended up being so simple.

@hugomosh
Copy link

hugomosh commented Feb 2, 2018

Is there a way to just skip/avoid some files to the sourcemap?

@JonathanFu
Copy link

@hugomosh
There is a simple one I found in other place.
We can now disable sourcemap with putting below setting in a .env file (at the root of the project):
GENERATE_SOURCEMAP=false

@serdarkaraca
Copy link

SET GENERATE_SOURCEMAP=false
npm run build

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

No branches or pull requests

5 participants