ghettovoice / vuelayers

Web map Vue components with the power of OpenLayers
https://vuelayers.github.io/
MIT License
683 stars 229 forks source link

set NODE_ENV for esm build #502

Closed lol2x closed 2 years ago

lol2x commented 2 years ago

Right now the ESM build does not have NODE_ENV and VUELAYERS_DEBUG variables set. This results in a bug when using Vue2 + Vite because vite does not expose process.env -> vite docs

image

This PR sets both variables for esm build.

ghettovoice commented 2 years ago

Hello @lol2x , I think this error should be fixed in other way... maybe by additional checking on existing of process.env and emulating it as an empty object.

Anyway if replace process.env.* in the vuelayers esm build then there is no possibility to use these env variables with app bundler. These variables are not replaced to allow your bundler replace them with what you need. I'm not very familiar with vite, but this way of lib bundling was something like a std way before vite. Probably there should be some way to workaround this issue, by a quick searching I found this plugin for vite https://github.com/ElMassimo/vite-plugin-environment