c12 icon indicating copy to clipboard operation
c12 copied to clipboard

Support `extends` from different config file name

Open DemoMacro opened this issue 2 years ago • 3 comments

Environment

node: v16.14.2 "c12": v1.1.2

Reproduction

https://stackblitz.com/edit/c12-bug-extends?file=index.mjs

Describe the bug

The extends option does not load configuration files in subdirectories, nor does it load configuration from npm packages.

❯ node index.mjs
Cannot extend config from `./base/config.dev.ts` in /home/projects/c12-bug-extends
{ config: true }

Additional context

No response

Logs

No response

DemoMacro avatar Feb 28 '23 01:02 DemoMacro

Hi. The config file in sub-directory should exist with expected name (config.ts). fixed sandbox

Is there a specific usecase you wanting to use .dev.ts in base?

pi0 avatar Feb 28 '23 10:02 pi0

Hi. The config file in sub-directory should exist with expected name (config.ts). fixed sandbox

Is there a specific usecase you wanting to use .dev.ts in base?

Changing the file name does work, but the official use case supports a similar configuration as config.dev.ts below, and it is clear that the extends option should not be restricted by naming, and any file specified as an expanded configuration should be loaded.

The following is stated in the official README and it is feasible that a configuration file of any name in a subdirectory should also be able to be loaded.

// config.ts
export default {
  colors: {
    primary: "user_primary",
  },
  extends: ["./theme", "./config.dev.ts"],
};

DemoMacro avatar Feb 28 '23 10:02 DemoMacro