admin管理员组文章数量:1324903
Hi I deploy my react using vite, however all the source code showing from debugger. I want to hide it and already follow the step:
- add
"build": "GENERATE_SOURCEMAP=false vite build",
- using cross-env
- and the last is try to set in vite config:
build: {
outDir: 'build',
chunkSizeWarningLimit: 1600,
assetsDir: './',
rollupOptions: {
input: './src/index.jsx'
},
sourcemap: 'false'
},
sourcemap: {
server: true,
client: true,
},
But all options not working.
Please see this image
I want source code not showing on debugger.
Hi I deploy my react using vite, however all the source code showing from debugger. I want to hide it and already follow the step:
- add
"build": "GENERATE_SOURCEMAP=false vite build",
- using cross-env
- and the last is try to set in vite config:
build: {
outDir: 'build',
chunkSizeWarningLimit: 1600,
assetsDir: './',
rollupOptions: {
input: './src/index.jsx'
},
sourcemap: 'false'
},
sourcemap: {
server: true,
client: true,
},
But all options not working.
Please see this image
I want source code not showing on debugger.
Share Improve this question asked Feb 27, 2023 at 8:28 EveEve 1222 gold badges3 silver badges11 bronze badges 1-
finally I change my vite.config.js. I create new vite react project and copy all my code into new project, because before I use CRA and migrate into VITE. Also using
build serve
on DO mand. Now all run well, debugger not showing sourcemap. – Eve Commented Mar 8, 2023 at 8:50
3 Answers
Reset to default 2You have to disable source maps. Here's how you can do :
- In your package.json, update the build script to include GENERATE_SOURCEMAP=false, like this :
"scripts": {
"build": "GENERATE_SOURCEMAP=false vite build"
}
- Then you have to install the cross-env package :
npm install --save-dev cross-env
- THen use cross-env to set the environment variable in the build script :
"scripts": {
"build": "cross-env GENERATE_SOURCEMAP=false vite build"
}
- Finally, in your vite.config.js set the sourcemap option to false :
module.exports = {
build: {
sourcemap: false
}
}
Don't forget to restart your server
You can disable sourcemap in vite.config.ts.
import { defineConfig } from "vite";
export default defineConfig({
build: { sourcemap: false }
});
For those who are still looking for a resolution, the following config worked for me:
export default defineConfig({
optimizeDeps: {
esbuildOptions: {
sourcemap: false,
}
},
build: {
sourcemap: false,
rollupOptions: {
output: {
sourcemapExcludeSources: true
}
}
},
// ... your other config
});
No GENERATE_SOURCEMAP
env var is required.
本文标签: javascriptHow to set GENERATESOURCEMAP false in viteStack Overflow
版权声明:本文标题:javascript - How to set GENERATE_SOURCEMAP false in vite - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742120419a2421667.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论