Skip to content

Commit

Permalink
Rewrite browserify config
Browse files Browse the repository at this point in the history
New plan is to attempt to make a single browserify
bundle of JS + Coffee and app + vendor. 

Thoughts:
* We'd remove concat_sourcemap if we could, but other plugins will want
to use it (conflicts) and we also want our global JST/templates to come
along.
* concat_sourcemap chokes on the sourcemaps from browserify, which are
provided as Data URIs. Can it be changed on either side to fix this? #7
* How do we provide multiple basepaths so vendor stuff can be loaded?
  • Loading branch information
searls committed Feb 27, 2014
1 parent 88960be commit 43ce317
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 19 deletions.
25 changes: 14 additions & 11 deletions config/plugins/browserify.coffee
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
module.exports = (lineman) ->
app = lineman.config.application

config:
loadNpmTasks: lineman.config.application.loadNpmTasks.concat("grunt-browserify")
loadNpmTasks: app.loadNpmTasks.concat("grunt-browserify")

prependTasks:
common: ["browserify"].concat(lineman.config.application.prependTasks.common)
common: ["browserify"].concat(app.prependTasks.common)

browserify:
app_js:
files:
"generated/js/browserifyBundle.js" : "<%= files.js.browserifyBundle %>"
options:
debug: true

app_coffee:
common:
files:
"generated/js/browserifyBundle.coffee.js" : "<%= files.coffee.browserifyBundle %>"
"<%= files.browserify.generated %>" : "<%= files.browserify.entrypoint %>"
options:
debug: true
debug: false
extensions: [".js", ".coffee"]
transform: ["coffeeify"]

watch:
browserify:
files: ["<%= files.js.vendor %>", "<%= files.js.app %>", "<%= files.coffee.app %>"]
tasks: ["browserify", "concat_sourcemap:js"]

11 changes: 11 additions & 0 deletions config/plugins/coffee.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = (lineman) ->
app = lineman.config.application

config:
removeTasks:
common: app.removeTasks.common.concat("coffee")

watch:
coffee:
files: []
tasks: []
19 changes: 13 additions & 6 deletions config/plugins/concat_sourcemap.coffee
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
_ = require("underscore")

module.exports = (lineman) ->
app = lineman.config.application

config:
concat_sourcemap:
js:
src: [
"<%= files.js.vendor %>"
"<%= files.js.browserifyBundle %>"
"<%= files.coffee.browserifyBundle %>"
"<%= files.template.generated %>"
]
src: _(app.concat_sourcemap.js.src).without(
"<%= files.js.vendor %>", "<%= files.js.app %>", "<%= files.coffee.generated %>"
).concat("<%= files.browserify.generated %>")


watch:
js:
files: []
tasks: []
5 changes: 5 additions & 0 deletions config/plugins/files.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = (lineman) ->
files:
browserify:
generated: "generated/js/browserify.js"
entrypoint: "app/js/entrypoint.{js,coffee}"
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@
"type": "git",
"url": "git://github.com/linemanjs/lineman-browserify.git"
},
"peerDependencies": {
"dependencies": {
"lineman": ">= 0.26.0",
"coffee-script": "~1.6.3",
"browserify": "~3.20.0",
"grunt-browserify": "~1.3.0",
"coffeeify": "~0.5.2",
"underscore": "~1.6.0"
},
"peerDependencies": {
"coffeeify": "~0.5.2"
},
"devDependencies": {
Expand Down

0 comments on commit 43ce317

Please sign in to comment.