lxs24sxl / vite-plugin-html-env

A vite plugin for rewriting html
82 stars 10 forks source link

Specifying mode removes every variable #3

Closed padcom closed 2 years ago

padcom commented 2 years ago

in Vite the mode can be specified in two ways:

npm run build -- --mode production

or

npm run build -- --mode=production

When using the latter syntax, no values are present in the resulting index.html.

padcom commented 2 years ago

The reason for such behavior is the very simple way of reading arguments and assuming the switch and its value will be 2 separate arguments. Maybe a better solution would be to take the mode from

export default defineConfig(({ mode }) => { ... })

That way, you don't need to re-parse the command-line arguments..

lxs24sxl commented 2 years ago

Thank you for the question, I have fixed this issue in 1.0.3.

Regarding the question why not get the mode parameter from defineConfig, I just want to make it easier for users.

padcom commented 2 years ago

Thank you! You're awesome!