Created
February 3, 2015 03:41
-
-
Save steverandy/63694b5ce016fcdc8d16 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gulp.task "bundle-scripts", -> | |
delete require.cache[require.resolve "./assets/bundles"] | |
bundles = require "./assets/bundles" | |
scripts = _.filter _.keys(bundles), (filename) -> | |
filename.indexOf(".js") >= 0 | |
merge _.map scripts, (filename) -> | |
if filename.indexOf(".js") is -1 then return | |
coffeeFilter = filter "**/*.coffee" | |
stream = gulp.src bundles[filename] | |
.pipe coffeeFilter | |
.pipe cache coffee() | |
.on "error", (err) -> | |
console.log err.toString() | |
@emit "end" | |
.pipe coffeeFilter.restore() | |
.pipe concat filename | |
if process.env.NODE_ENV is "production" | |
stream.pipe uglify() | |
stream.pipe gulp.dest "public/assets/bundles" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment