Declarative path mapping and concatenation for gulp.
npm install gulp-empathy
empathy = require 'gulp-empathy'
{task} = empathy require('gulp'),
source: 'src'
target: 'build'
ignore: ['**/_*', '**/_*/**']
map:
markup: '**/*.{html,jade}'
styles:
'styles/app.css': '**/*.{css,styl}'
'styles/vendor.css': [
'./vendor/normalize.css'
'./vendor/grid.css'
]
task 'markup', ->
@stream.pipe $.if '*.jade', jade()
task 'styles', ->
@stream
.pipe $.if '*.styl', stylus()
.pipe csso()
A working example can be seen here.
Instead of using gulp.src or gulp.dest, use only @stream. All other gulp rules apply (such as a function callback or returning a stream).
You can assign a function to @after inside of a task (do this before you use @stream, since it needs to be returned) and it will be called after gulp.dest (useful for streaming changes) Return the result of stream.pipe from @after's callback.
Any path that begins with '.' (for instance './' or '../') will not have source or target paths prefixed. This is useful for sourcing files from, for example, './node_modules/' or './bower_components/'.