You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I asked a similar question on StackOverflow (https://stackoverflow.com/q/78451880/195835) but perhaps it's worth raising here, also. Here is what I tried adding to my vite.config.js.
export defaultdefineConfig({
...
esbuild: {drop: ['console'],// this line works!dropLabels: ['DEV'],// this one doesn't!}})
For some reason the drop option does what it's supposed to (strips all console.*() calls), but the dropLabels option does not (well the labels get removed, but not the code next to the label). Some responses indicated that this is because esbuild is not used during production builds, but if that's the case, why does the drop option work?
(The dev server will run by default, and you can view the console.log's by opening your browser dev tools. To run a production build, quit the dev server with Q, ENTER and then type npm run build && cat dist/assets/index*.js and you will see the production bundle JS output.)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I asked a similar question on StackOverflow (https://stackoverflow.com/q/78451880/195835) but perhaps it's worth raising here, also. Here is what I tried adding to my
vite.config.js
.For some reason the
drop
option does what it's supposed to (strips allconsole.*()
calls), but thedropLabels
option does not (well the labels get removed, but not the code next to the label). Some responses indicated that this is because esbuild is not used during production builds, but if that's the case, why does thedrop
option work?To reproduce this, here's a simple StackBlitz that demonstrates it:
https://stackblitz.com/edit/vitejs-vite-4uczvd?file=src%2Fmain.js,vite.config.js&terminal=dev
(The dev server will run by default, and you can view the
console.log
's by opening your browser dev tools. To run a production build, quit the dev server withQ
,ENTER
and then typenpm run build && cat dist/assets/index*.js
and you will see the production bundle JS output.)Beta Was this translation helpful? Give feedback.
All reactions