isaurssaurav / hot-reload-extension-vite-plugin

Simple vite plugin to reload chrome extension on file change.
MIT License
19 stars 4 forks source link

`process.env` references prevents the script from loading. [Suggestion: Use Vite's env variables] #7

Open insidewhy opened 5 months ago

insidewhy commented 5 months ago

Using build.lib to produce my output, there's two lines in the produced code that prevent the code from running:

process.env.NODE_ENV;

Not sure why this is here, it doesn't do anything.

var k = process.env.HOT_RELOAD_EXTENSION_VITE_PORT ? parseInt(process.env.HOT_RELOAD_EXTENSION_VITE_PORT) : ...

I think vite uses import.meta now instead of process.env for stuff like this

insidewhy commented 5 months ago

By replacing process.env with import.meta.env in the source I was able to get this working

insidewhy commented 5 months ago

I was building my extension with lib.formats: ['es'], switching 'es' to 'cjs' fixed it

isaurssaurav commented 4 months ago

@insidewhy, Thank you for posting this issue.

You are right. The package is not using vite's env vairables. It makes more sense to use it. I will re-open this issue and work on it.