mattdesl / budo

:clapper: a dev server for rapid prototyping
MIT License
2.17k stars 106 forks source link

.budorc config file #126

Closed scottcorgan closed 8 years ago

scottcorgan commented 8 years ago

I was curious if it has been considered to add a dot config file (like bable/eslint)? My script line gets pretty long with my options:

"scripts": {
  "start": "budo src/index.js --pushstate --port 3000 --live --title=\"My Title\" --no-debug --onupdate=\"npm run lint\" --css dist/index.css  -- -t [ babelify ] -p [ css-modulesify -o dist/index.css ]"
}

Thoughts?

mattdesl commented 8 years ago

I have seen some pretty long npm scripts too, and it tends to get a bit out of hand. I'm a bit hesitant to add .budorc or some other config (like in package.json) since it adds another layer of complexity for those not familiar with budo, and also pushes the config away from the command itself (so it isn't immediately clear what flags are set). I am trying my best to avoid turning budo into another behemoth like webpack or babel.

A couple other ways of keeping things small and DRY:

  1. You can specify "browserify": { "transform": "babelify" } in package.json. This field doesn't support plugins, and isn't useful if you need different dev/prod transforms. It's also no good if you are building a module/lib, instead of an app.
  2. You can use shorthand flags. Not as clear in the package.json, but maybe better than a super long command.
  3. You can split it into a dev.sh or dev.js file. For example:
#!/usr/bin/env node

// in `tasks/dev.js`
require('budo').cli(process.argv.slice(2), {
  pushstate: true,
  port: 3000,
  live: true,
  title: 'Foo',
  debug: false,
  serve: 'bundle.js',
  onupdate: 'npm run lint',
  css: 'dist/index.css',
  browserify: {
    transform: [ 'babelify' ],
    plugin: [ ... ]
  }
});

And then:

  "scripts": {
    "start": "./tasks/dev.js src/index.js"
  }

I'm open to more ideas / discussion, though. :smile:

scottcorgan commented 8 years ago

Fair enough. Probably a good idea to keep it focused. I'll write a script or a wrapper around budo for this feature. Thanks for the consideration!