Create-react-app: Production deploy - How to remove/disable webpack source-map

Created on 3 Nov 2016  路  8Comments  路  Source: facebook/create-react-app

screen shot 2016-11-04 at 1 24 47 am

Thanks so much!!!

Most helpful comment

For those coming here from google:

cross-env GENERATE_SOURCEMAP=false npm run build

All 8 comments

You can delete .js.map files from build/static/js as a deployment step if you prefer so.

I think it could be very useful to have a build:dev script if you want to use sourcemps, who wants to make a build for production with sourcemaps? I think its very strange.

Now I have a script to delete the sourcemaps and also revoming sourcemaps comments in main.js and main.css in order to avoid browser dispathing "source map not found" warning. I find this solution very dirty.

who wants to make a build for production with sourcemaps? I think its very strange.

I wouldn't say so. They are super useful for error reporting for example, as well as for analysing bundle size from dependencies. Whether you choose to deploy them or not is your choice, but producing them is useful.

There's an ongoing discussion in https://github.com/facebookincubator/create-react-app/issues/1341 so feel free to track it. I'm open to other solutions so please suggest them there.

Thanks @gaearon , I continue the discussion there :)

For those coming here from google:

cross-env GENERATE_SOURCEMAP=false npm run build

In a Vue.js project using Webpack see the ./config folder on the index.js file. Change the line:

productionSourceMap: true

to

productionSourceMap: false

This works for me. Hope it help anyone.
// package.json

"build": "react-scripts build",
"postbuild": "rimraf build/**/*.map"

This way, it will auto delete map files during build generation.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alleroux picture alleroux  路  3Comments

fson picture fson  路  3Comments

adrice727 picture adrice727  路  3Comments

Evan-GK picture Evan-GK  路  3Comments

fson picture fson  路  3Comments