I have always placed different "tooling configurations" in their own files in my front-end projects.
For example: babel in babel.config.js
, jest in jest.config.js
, eslint in an .eslintrc.json
, etc.
I have noticed recently however that it is possible to place many of these configurations directly in a projects package.json
file instead.
I did some digging around online and asked a few colleagues but no-one can seem to give me a definitive answer as to why one might prefer one approach over the other.
Is it purely a matter of preference?
Data from config. json is used to configure virtual machine. After editing file make sure that your JSON syntax is valid. JSONLint can help to check it.
Node-config allows you to create configuration files in your Node application for different deployment environments. With it, you can define a default configuration file that you intend to repeat across environments, then extend the default config to other environments, such as development, staging, etc.
Yes, you're allowed to add custom entries to package. json .
This package. json is used by all projects in the workspace, including the initial application project that is created by the CLI when it creates the workspace. Initially, this package. json includes a starter set of packages, some of which are required by Angular and others that support common application scenarios.
My suggestion is to avoid stuffing package.json
with custom configs mainly for two reasons.
First is regarding developer expectations. Putting yourself in the position of a person that is just getting off with JavaScript and NPM ecosystem, you see something that's not documented, at least not where you expect it to be. This kind of experience could easily drive folks away especially if they come from more strict developer platforms and languages.
Second, keyword collision or more importantly the thought of such being possible. We don't expect NPM to consider not using some keyword in the future just because some shiny new lib is using it too, do we?
On the other hand having dedicated files for babel, browserlist, postcss is such more simple, self-explanatory approach and every single of those projects already recommends using dedicated files for configurations.
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