Search code examples
javascriptreactjsnode.jsdeploymentserve

Serve deploy with only bundle files


I'm following the Tic-Tac-Toe tutorial from the React, I have the build folder and I want to deploy it with serve lib, my expection is when hit F12 and go to the source tab that only show the bundle files not js raw files (App.js and index.js), how to do that guys?

The Source tab in the Devtools

enter image description here


Solution

  • What you are looking for is deploying without source maps. Source maps are used by the browser to reconstructs your files into "raw" files.

    To solve this problem you need to generate a build without source maps, to do this you need to set GENERATE_SOURCEMAP=false (read more), here is example how you can do this with adding it in your package.json

    // If you use Linux
    "scripts": {
      "build": "GENERATE_SOURCEMAP=false react-scripts build"
    }
    
    // if you use Windows
    // NOTE: I have not used Windows in a long time, so this might have errors
    "scripts": {
      "build": "set \"GENERATE_SOURCEMAP=false\" && react-scripts build"
    }
    

    In dev mode, source maps are enabled by default from CRA for easier debugging