-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
51 lines (37 loc) · 1.43 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
var gulp = require('gulp');
var coffee = require('gulp-coffee');
var uglify = require('gulp-uglify')
var gulpif = require('gulp-if');
var elixir = require('laravel-elixir');
var utilities = require('laravel-elixir/ingredients/commands/Utilities');
var Notification = require('laravel-elixir/ingredients/commands/Notification');
/*
|----------------------------------------------------------------
| CoffeeScript Compilation
|----------------------------------------------------------------
|
| This task will compile your CoffeeScript, minify it, and then
| optionally generate a "manifest" file that helps with your
| browser cache-busting of previous versions of your code.
|
*/
elixir.extend('coffeedir', function(src, output, options) {
var config = this;
var baseDir = config.assetsDir + 'coffee/';
var search = '**/*.coffee';
var options = options || {};
var onError = function(e) {
new Notification().error(e, 'CoffeeScript Compilation Failed!');
this.emit('end');
};
src = utilities.buildGulpSrc(src, baseDir, search);
gulp.task('coffeedir', function() {
return gulp.src(src)
.pipe(coffee(options).on('error', onError))
.pipe(gulpif(config.production, uglify()))
.pipe(gulp.dest(output || config.jsOutput))
.pipe(new Notification().message('CoffeeScript Compiled!'));
});
this.registerWatcher('coffeedir', baseDir + search);
return this.queueTask('coffeedir');
});