process.env.npm_package_version is missing when building for production using vite

Viewed 21

I'm trying to access process.env.npm_package_version in vite.config.ts. It works in dev, but in production it's says that it's undefined.

export default defineConfig({
    define: {
      __VERSION__: JSON.stringify(process.env.npm_package_version),
    },
});

Having logged process.env, all the NPM env vars are missing in production. Is there any way to access it?

0 Answers
Related