Skip to content
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

feat(bankai): simplify #86

Merged
merged 18 commits into from
Nov 5, 2016
Merged

feat(bankai): simplify #86

merged 18 commits into from
Nov 5, 2016

Conversation

yoshuawuyts
Copy link
Member

@yoshuawuyts yoshuawuyts commented Nov 3, 2016

This paves the way for some more fancy things; much needed spring cleaning

changes

  • change JS API (no more event emitters)
  • change CLI API (less options, use subargs)
  • remove a lot of code
  • unvendor deps
  • remove clunky tests

todo

  • patch watchify-request to detect if res exists
  • fix bug where bankai build doesn't exit when done

CLI API

  Usage:
    $ bankai <command> [options]

  Commands:
    <default>                      Run 'bankai start'
    start <filename>               Start a bankai server
    build <filename> <directory>   Compile and export files to a directory

    Options:
      -c, --css=<subargs>     Pass subarguments to sheetify
      -h, --help              Print usage
      -j, --js=<subargs>      Pass subarguments to browserify
      -o, --open=<browser>    Open html in a browser [default: system default]
      -O, --optimize          Optimize assets served by bankai [default: false]
      -p, --port=<n>          Bind bankai to <n> [default: 8080]

  Examples:
    $ bankai index.js -p 8080            # start bankai on port 8080
    $ bankai index.js --open             # open html in the browser
    $ bankai -c [ -u sheetify-cssnext ]  # use cssnext in sheetify
    $ bankai -j [ -t brfs ]              # use brfs in browserify
    $ bankai build index.js dist/        # compile and export to dist/
    $ bankai build -O index.js dist/     # optimize compiled files

JS API

const bankai = require('bankai')
const http = require('http')
const path = require('path')

const clientPath = path.join(__dirname, 'client.js')
const assets = bankai(clientPath)

http.createServer((req, res) => {
  switch (req.url) {
    case '/': return assets.html(req, res).pipe(res)
    case '/bundle.js': return assets.js(req, res).pipe(res)
    case '/bundle.css': return assets.css(req, res).pipe(res)
    default: return (res.statusCode = 404 && res.end('404 not found'))
  }
}).listen(8080)

@bcomnes
Copy link
Collaborator

bcomnes commented Nov 3, 2016

Live reload?

@yoshuawuyts
Copy link
Member Author

Not yet, minor patch on top of this

On Thu, Nov 3, 2016, 4:57 AM Bret Comnes [email protected] wrote:

Live reload?


You are receiving this because you authored the thread.

Reply to this email directly, view it on GitHub
#86 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACWleky7TyHpTSEw65NJvIHrJIdUiWQZks5q6Vu4gaJpZM4Kn7rg
.

@yoshuawuyts
Copy link
Member Author

tho it's looking pretty good; should be easy to add hey:

@aknuds1
Copy link
Contributor

aknuds1 commented Nov 3, 2016

@yoshuawuyts Is Ben Gourley's work an alternative to my live reload patch?

@yoshuawuyts
Copy link
Member Author

@aknuds1 yup; like I said in the beginning - using hot module reload stuff is preferable over using tiny-lr and friends not only because it's simpler - it's also a nicer workflow and less strain on the CPU

@aknuds1
Copy link
Contributor

aknuds1 commented Nov 3, 2016

@yoshuawuyts Ah, I must've missed what you said about hot module reload.

@bcomnes
Copy link
Collaborator

bcomnes commented Nov 3, 2016

I've had some frustrations with HMR in the past with redux/react apps. I'm open to see how it works with choo though.

@yoshuawuyts
Copy link
Member Author

@bcomnes never tried it properly before; real curious how it'll turn out - if anything having the option will be sw-eet

@yoshuawuyts
Copy link
Member Author

all is good - merging!

@yoshuawuyts yoshuawuyts merged commit 1ee75a8 into master Nov 5, 2016
@yoshuawuyts yoshuawuyts deleted the change-bin branch November 5, 2016 02:59
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

Successfully merging this pull request may close these issues.

3 participants