UNPKG

1.55 kBJavaScriptView Raw
1var gulp = require('gulp');
2var $ = require('gulp-load-plugins')();
3
4var paths = {
5 scripts: ['src/infra.coffee','src/axoid.coffee','src/commons/**/*.coffee']
6};
7
8gulp.task('scripts', function() {
9 return gulp.src(paths.scripts)
10 .pipe($.cached('scripts')) // only pass through changed files
11 //.pipe(jshint()) // do special things to the changed files...
12 .pipe($.plumber())
13 .pipe($.coffee())
14 .on('error', console.log)
15 //.pipe(uglify())
16 .pipe($.remember('scripts')) // add back all files to the stream
17 .pipe($.concat('index.js')) // do things that require all files
18 .pipe(gulp.dest(''))
19 .pipe($.uglify())
20 .pipe($.concat('index.min.js')) // do things that require all files
21 .pipe(gulp.dest(''))
22 ;
23});
24
25// Rerun the task when a file changes
26gulp.task('watch', function() {
27 var watcher = gulp.watch(paths.scripts, ['scripts']); // watch the same files in our scripts task
28 watcher.on('change', function (event) {
29 if (event.type === 'deleted') { // if a file is deleted, forget about it
30 delete $.cached.caches.scripts[event.path]; // gulp-cached remove api
31 $.remember.forget('scripts', event.path); // gulp-remember remove api
32 }
33 });
34
35});
36
37// The default task (called when you run `gulp` from cli)
38gulp.task('build', ['scripts']);
39
40// The default task (called when you run `gulp` from cli)
41gulp.task('default', ['watch', 'scripts']);