nuxt-env icon indicating copy to clipboard operation
nuxt-env copied to clipboard

Adding support for top-level options configuration

Open fnavarijo opened this issue 5 years ago • 1 comments

Update: Adding top-level configuration module support

This update let users to configure keys via top-level options. I think this enhancement let users organize in a better way the env keys that will be injecting to the project. I only added this enhancement, the behavior to inject via env prop and module options keeps the same Here is an example

module.exports = {
  env: {
    SOME_COOL_ENV: 'cool value',
  },
  modules: [
    ['nuxt-env', {
        keys: [
            'TEST_ENV_VAR', // Basic usage—equivalent of { key: 'TEST_ENV_VAR' }
            { key: 'OTHER_ENV_VAR', default: 'defaultValue' } // Specify a default value
            { key: 'THIRD_ENV_VAR', secret: true } // Only inject the var server side
            { key: 'ANOTHER_ENV_VAR', name: 'MY_ENV_VAR' } // Rename the variable
        ]
    }]
  ],
  // Now we can configure the keys this way too
  nuxtenv: {
    keys: [
        'TEST_ENV_VAR', // Basic usage—equivalent of { key: 'TEST_ENV_VAR' }
        { key: 'OTHER_ENV_VAR', default: 'defaultValue' } // Specify a default value
        { key: 'THIRD_ENV_VAR', secret: true } // Only inject the var server side
        { key: 'ANOTHER_ENV_VAR', name: 'MY_ENV_VAR' } // Rename the variable
    ]
  }
};

Any suggestion or correction you think must be made, let met know to do it.

Thanks for this awesome project.

PD. I also updated circle pipeline definition to use npm.

fnavarijo avatar Apr 10 '20 00:04 fnavarijo

Thanks for this PR, I'm hoping this will get merged and released soon because this can be really usefull.

lefuturiste avatar Apr 29 '20 22:04 lefuturiste