c12 icon indicating copy to clipboard operation
c12 copied to clipboard

Allow overridng extends with env

Open pi0 opened this issue 3 years ago • 2 comments

Related to #16

Allow adding extends with {NAME}_EXTENDS. (It is differently handled from #16 since should happen before config resolution)

Notes:

  • We might allow splitting with , for multiple values
  • It is limited to source without options (https://github.com/unjs/c12/issues/9)
  • ~~We need to find a convention to override instead of adding to other extends values~~ (multiple extend keys can be used for overriding)

pi0 avatar Jul 13 '22 11:07 pi0

Regarding #9 I don't see a use case so far.

For the convention to override, I believe NUXT_EXTENDS is a special case since it is a special feature: https://github.com/unjs/c12#extending-configuration

atinux avatar Jul 13 '22 11:07 atinux

We might need to pass an additional param to extend config for overriding top level extends with possible env. I agree it makes sense for some usecases (replacing layer with a development version) but also is tricky specially with #9. Imagine we need to pass some options such as license key or theme options to a layer but extending it's source to a local one.

pi0 avatar Jul 13 '22 11:07 pi0

@Atinux With introduction of env configs, do you still have usecases for this env?

pi0 avatar Mar 15 '23 13:03 pi0

Not much, actually I leverage a .env with:

MY_THEME/my/theme/path

And use:

extends: process.env.MY_THEME || 'my-theme'

So can be closed IMO

atinux avatar Mar 15 '23 15:03 atinux

(pr welcome or feel free to directly add this as an example to the docs)

pi0 avatar Mar 15 '23 15:03 pi0