Search code examples
reactjscreate-react-appnetlify

No source map when deploying a Create React App to Netlify


Deploying to Netlify using create-react-app.

Issue:

  • Not build the source map for production deploy.
  • Have the source map for other builds for debugging.

Solution

  • Solution:

    Add the GENERATE_SOURCEMAP env variable to flag no source map. Edit the netlify.toml to include the variable for use in build contexts.

    netlify.toml

    [build]
      command = "npm run build"
      publish = "build"
    
    [build.environment]
      GENERATE_SOURCEMAP = "true"
    
    [build.production.environment]
      GENERATE_SOURCEMAP = "false"