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 leaking into production bundle #356

Closed foxxyz closed 1 year ago

foxxyz commented 1 year ago

Description

vite recently changed the signature for resolveConfig() to take a 4th argument defaultNodeEnv, which by default is set to development.

Since this argument is not added when resolveConfig is called in vite-ssg, it causes NODE_ENV to get set to development.

n turn, this triggers vite-plugin-vue to consider this a development build, inserting absolute file paths into the bundle.

This PR adds the correct defaultNodeEnv so NODE_ENV is correctly set to production during a production build.

(Note: vite does the exact same when calling vite build)

Linked Issues

354 #349

foxxyz commented 1 year ago

@antfu thank you! And thank you for all the work you do for the Vue community! We appreciate it!