In order to disable source maps in Vite so that users cannot view the code through the browser we need to do two things:
- Install the package
cross-env:npm install --save-dev cross-env. - In the
scriptsobject in thepackage.jsonfile add the following to thebuildcommand:cross-env GENERATE_SOURCEMAP=false vite build. - In the vite config file
vite.config.jsorvite.config.tsadd the following insidedefineConfig:build: {sourcemap: false}.