I have several repositories that share so much of the same sorts of configuration files (e.g. .eslintrc, .babelrc, karma.conf.js) along with other sorts of utility files. I'd love to be able to extract these out and be able to leverage them across all repos. What are some of the best ways for achieving this?
npm module. Then, import it and use it as needed?I feel that option 1 would be ideal, however, I'm not sure how one would be able to reference a file that is not exported. For example, how would one repo make use of the .eslintrc file within this npm module?
Symlinking won't work well when you need to run builds and tests on a CI server, but it might be worth checking out lerna which wraps multiple packages in a monorepo.
I've tried the CLI approach, but ended up going with private npm "micro" modules, that I just drop in the package.json as needed.
What went wrong with the CLI:
To use a specific .eslintrc from within an npm module, you can pass eslint a --config arg with your .eslintrc path.
Bear in mind that these tools (eslint, babel, karma, mocha, etc) are sometimes a pain to configure and update, so it is a good idea to keep your codebase self-contained, and duplicate the config files instead of having abstraction layers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With