build icon indicating copy to clipboard operation
build copied to clipboard

Shareable configurations

Open ehmicky opened this issue 6 years ago • 8 comments

We could allow configurations to be shareable like ESLint does.

This could be as simple as adding an extends property that points to either a Node.js module name, or to a file path. The shared configuration would be deeply merged, with lower merging priority.

We could also have naming conventions such as netlify-build-config-*. And npm tags and GitHub tags netlify and netlify-build-config.

What do you think?

ehmicky avatar Oct 03 '19 09:10 ehmicky

related https://github.com/netlify/build/issues/18

swyxio avatar Oct 03 '19 12:10 swyxio

Not sure I follow. How does this materialize? A extends key on a plugin declarations in netlify.yml|toml?

DavidWells avatar Oct 03 '19 16:10 DavidWells

Yes for example, let's say there's a Node.js module named my-shared-netlify-config that exports the following netlify.json:

{
  "build": {
    "lifecycle": {
      "init": "echo init",
      "build": "echo this does not have priority"
    }
  }
}

Then the following netlify.yml:

extends: my-shared-netlify-config
build:
  lifecycle:
    getCache: echo getCache
    build: echo this has priority

Would resolve to:

build:
  lifecycle:
    init: echo init
    getCache: echo getCache
    build: echo this has priority

ehmicky avatar Oct 03 '19 17:10 ehmicky

I see. This would make reading the build instructions more difficult (unless you understood what extend does under the hood and where it resolves from)

For now we should keep this as simple and explicit as possible.

It's possible for users to achieve this functionality in userland via yml extend << and other variables.

Lets hold off on this for now until we see feature requests on this

DavidWells avatar Oct 03 '19 17:10 DavidWells

It's possible for users to achieve this functionality in userland via yml extend << and other variables.

<< only allows merging within the same file, not merging other files or importing Node.js modules.

This would make reading the build instructions more difficult (unless you understood what extend does under the hood and where it resolves from)

This would be done by @netlify/config during configuration loading. Since we are supporting several file formats, anyone who wants to operate on configuration objects has to use that configuration loading function anyway. Unless you meant something else by "reading the build instructions"?

Lets hold off on this for now until we see feature requests on this

I think this should be straightforward to implement (just need to make a require() call and use a deep-merge library) but we can hold off on this if you think this might not be needed. :+1:

ehmicky avatar Oct 03 '19 18:10 ehmicky

couldshould

Let's hold off on this for right now. I will show you how it's possible in userland

DavidWells avatar Oct 03 '19 18:10 DavidWells

We need this for plugin presets: #370.

ehmicky avatar Oct 24 '19 12:10 ehmicky

Mentioned in https://github.com/f22hd/netlify-plugin-nx-skip-build/issues/1#issuecomment-953186352

ehmicky avatar Oct 28 '21 15:10 ehmicky

This issue has been automatically marked as stale because it has not had activity in 1 year. It will be closed in 14 days if no further activity occurs. Thanks!

github-actions[bot] avatar Oct 29 '22 14:10 github-actions[bot]

This issue was closed because it had no activity for over 1 year.

github-actions[bot] avatar Nov 13 '22 14:11 github-actions[bot]