Skip to content

Support custom configuration file #225

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Ailrun opened this issue Jun 6, 2018 · 7 comments
Closed

Support custom configuration file #225

Ailrun opened this issue Jun 6, 2018 · 7 comments

Comments

@Ailrun
Copy link

Ailrun commented Jun 6, 2018

Do you want to request a feature or report a bug?
Request a feature

What is the current behavior?
Read the package.json

If this is a feature request, what is motivation or use case for changing the behavior?
I want to separate configs into specific directory.

Please mention other relevant information.

  • node version: 9.11.1
  • npm version: 6.0.0
  • Operating system: Manjaro
  • bundlesize version: 0.17.0
  • CI you are using: TravisCI
@trevordmiller
Copy link

trevordmiller commented Jun 24, 2018

Agreed. It would be nice to have a .bundlesizerc.json file option for those who like to keep config out of package.json and npm scripts (following other tools: .babelrc, .eslintrc.json, .lintstagedrc.json, .prettierrc.json, now.json, etc.).

Thanks for the great tool!

@ghost
Copy link

ghost commented Aug 10, 2018

Would love this feature too. I'm currently working on a project that makes heavy use of code splitting and produces about 10 different chunks at build time. I've set up bundlesize to check each chunk against a specific limit, with different compressions, which is great.

The downside is that my package.json is now twice as big due to this. It would be fantastic to be able to call bundlesize -c ./path/to/.bundlesizerc or similar.

@trevordmiller
Copy link

trevordmiller commented Aug 11, 2018

For example, right now I have an npm script that looks like this:

"size": "bundlesize -f './.next/main.js' -s 150kB"

It would be nice if I could move all the config to a .bundlesizerc.json configuration file like the package.json bundlesize options:

[
  {
    "path": "./.next/main.js",
    "maxSize": "150kB"
  }
]

Then the npm script could simply be:

"size": "bundlesize"

@Aghassi
Copy link

Aghassi commented Aug 25, 2018

Adding this should be very straight forward. https://github.com/davidtheclark/cosmiconfig can be added as a dependency, and it takes very few lines of code. @siddharthkp, I can take this on unless there is any objection to using this package.

@trevordmiller
Copy link

That would be awesome. cosmiconfig is what many other tools use. Prettier, for example: https://prettier.io/docs/en/configuration.html

@ssulivan11
Copy link

Have a custom config setting in this PR:
#212

In our monorepo we maintianed hundreds of individual bundles and the package.json got ugly 😊

@siddharthkp
Copy link
Owner

siddharthkp commented Jun 29, 2019

Implemented in #316 and published in 0.18.0 🎉

Check out README for details

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants