Closed ListenV closed 1 year ago
I have seen this as well. It seems the build output changed since Vite 2, not surprising. I wasn't able to figure out why this happened, but library mode makes sense...
The workaround I'm currently using:
export default defineConfig({
...
defines: {
process.env: JSON.stringify({}),
}
})
this works because, at least for me, process.env
was the only value accessed on process
.
I'll work on fixing the default config... Setting build.target
seems like a likely fix.
build.target
did not effect this. Instead, I'm automatically defining process.env.NODE_ENV
based on vite's mode (usually "development" or "production").
Also, according to Vite's docs, this is the only env reference output from library mode.
See https://github.com/aklinker1/vite-plugin-web-extension/pull/98
Summary
The compiled output includes
process.env
.eg:
background.js
andcontent_script.js
.As far as I know, it's build in vite's Library Mode.
process.env
variable not work in browserEnvironment