antfu-collective / vite-ssg

Static site generation for Vue 3 on Vite
MIT License
1.27k stars 129 forks source link

fix: absolute `__file` paths still leaking when building in alternate non-development modes #362

Closed foxxyz closed 11 months ago

foxxyz commented 12 months ago

Description

Add-on to #356 which fixed part of the problem, but building in alternate modes can still cause the issue. For example:

vite-ssg build --mode staging

Will correctly run a vite bundle in staging mode, but because of the issue detailed in #356 will also set NODE_ENV to staging, which makes vite-plugin-vue think this is a development build and leak __file paths.

If I understand correctly, NODE_ENV should really only ever be production or development (same as unset), so this PR sets the default NODE_ENV to production for any other mode except development.

(An alternate solution would be to do what vite does and set this to the hardcoded string production. Either one would solve the problem, let me know which you'd prefer.)

Linked Issues

354 #349