Skip to content

Instantly share code, notes, and snippets.

@hhsnopek
Last active August 29, 2015 14:03
Show Gist options
  • Save hhsnopek/d76454e875c89d7ea024 to your computer and use it in GitHub Desktop.
Save hhsnopek/d76454e875c89d7ea024 to your computer and use it in GitHub Desktop.
roots component

Roots Component working hack

  1. create component.json NOTE: Whatever you use as the name in this will be same name you use in step 3
  2. add your components and list /public/js/main.js as your script
  3. in layout.jade remove the require.js script and add:

script(src="js/build.js")
script.
  require('name-from-component.js')

  1. npm install component-builder component-resolver --save
  2. in app.coffee require component-builder, component-resolver, & fs then under module.exports = add this
after: (roots, cb) ->

  resolve(process.cwd(),
    install: true
    , (err, tree) ->
      if err then cb(err)

      build.scripts(tree)
        .use('scripts', build.plugins.js())
        .end((err, str) ->
            if err then cb(err)

            fs.writeFile("./public/js/build.js"
              , build.scripts.require + str
              , cb
            )
        )
  )
  1. If you didn't install the component dependencies, roots watch or roots compile will do that for you
  2. run roots watch and see the magic happen!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment