Skip to content

Instantly share code, notes, and snippets.

@chrisabrams
Last active August 29, 2015 14:01
Show Gist options
  • Save chrisabrams/c61281407de41635d454 to your computer and use it in GitHub Desktop.
Save chrisabrams/c61281407de41635d454 to your computer and use it in GitHub Desktop.
Chaplin + Browserify
glob = require 'glob'
grunt = require 'grunt'
util = require 'util'
aliasMappingsToAliasArray = (aliasMappings) ->
aliasArray = []
aliases = (if util.isArray(aliasMappings) then aliasMappings else [aliasMappings])
aliases.forEach (alias) ->
grunt.file.expandMapping(alias.src, alias.dest,
cwd: alias.cwd
).forEach (file) ->
expose = file.dest.substr(0, file.dest.lastIndexOf("."))
pa = "./" + file.src[0] + ":" + expose
aliasArray.push pa
return
return
return aliasArray
module.exports =
vendor:
dest: '<%= roots.ready %>/vendor.js'
src: []
options:
browserifyOptions:
fullPaths: false
alias: [
'./node_modules/backbone/backbone.js:backbone'
'./node_modules/jquery/dist/jquery.js:jquery'
'./node_modules/handlebars/dist/handlebars.js:handlebars'
'./node_modules/hbsfy/runtime.js:hbsfy/runtime'
'./node_modules/lodash/dist/lodash.js:lodash'
'./node_modules/underscore/underscore.js:underscore'
]
app:
dest:'<%= roots.ready %>/app.js'
src: [
#'<%= roots.app %>/**/*.coffee'
'<%= roots.app %>/*.coffee'
'<%= roots.app %>/lib/**/*.coffee'
'<%= roots.app %>/models/**/*.coffee'
'<%= roots.app %>/strings/**/*.coffee'
'<%= roots.app %>/views/**/*.coffee'
'<%= roots.app %>/**/*.js'
#'<%= roots.app %>/**/*.hbs'
]
options:
browserifyOptions:
extensions: [ '.coffee', '.hbs' ]
fullPaths: false
bundleOptions:
debug: true
transform: [ 'coffeeify', 'hbsfy' ]
external: [
'backbone'
'handlebars'
'hbsfy/runtime'
'jquery'
'lodash'
]
alias: aliasMappingsToAliasArray(
[
cwd: './app/controllers'
src: [
'**/*.coffee'
'**/*.js'
]
dest: 'controllers'
,
cwd: './app/templates'
src: [
'**/*.hbs'
]
dest: '../templates'
]
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment