eslint icon indicating copy to clipboard operation
eslint copied to clipboard

validate environment variables used in `runtimeConfig`

Open danielroe opened this issue 2 years ago • 5 comments

they need to match the object pattern - would be nice if we could provide support for this

danielroe avatar Jan 27 '23 20:01 danielroe

Maybe move to plugin repo?

pi0 avatar Jan 27 '23 20:01 pi0

I was thinking to rename to nuxt/eslint and include plugin in this repo.

danielroe avatar Jan 27 '23 21:01 danielroe

Looks good to me!

atinux avatar Feb 20 '23 13:02 atinux

@danielroe Could you elaborate more on what you expect on this? I could give it a try

antfu avatar Mar 21 '24 11:03 antfu

I'm thinking:

export default defineNuxtConfig({
  runtimeConfig: {
    // should be process.env.NUXT_GITHUB_TOKEN
    githubToken: process.env.MY_GITHUB_TOKEN,
    public: {
      // should be process.env.NUXT_PUBLIC_SOME_VAR
      someVar: process.env.SOMEVAR
    }
  }
})

The reason being that often people are not aware that their nuxt config isn't 'reread' in production. And they may have these variables set in an env - which works in dev, but will fail when built.

It should also be valid to set these variables to some value without referencing process.env

danielroe avatar Mar 21 '24 11:03 danielroe