forked from nyxgear/formtools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
81 lines (63 loc) · 1.94 KB
/
gulpfile.js
File metadata and controls
81 lines (63 loc) · 1.94 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
'use strict';
var gulp = require('gulp'),
gutil = require('gulp-util'),
sourcemaps = require('gulp-sourcemaps'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
plumber = require('gulp-plumber'),
sequence = require('gulp-sequence'),
eslint = require('gulp-eslint'),
size = require('gulp-size'),
rename = require('gulp-rename');
//gulp.task('default', function() {
// return gutil.log('Gulp default\n\n gulp monitor\t\tWatch mode\n gulp release\t\tRelease (minify)');
//});
gulp.task( 'default',
function () {
gutil.log('\n'+
gutil.colors.green('GULP TASKS') + '\n\t' +
// default | help
gutil.colors.yellow('default | help') + '\n\t\t' +
'Shows the available tasks\n\n\t' +
// monitor
gutil.colors.yellow('monitor') + '\n\t\t' +
'Real time check for changes in js files.\n\t\tIt handles errors and rebuilds the minified and compiled files.\n\n\t' +
// release
gutil.colors.yellow('release') + '\n\t\t' +
'Rebuild and concatenate all js files.\n\t\tIt minify and uglify js for deploy.\n\t\t'
);
}
);
gulp.task('monitor', function () {
return sequence(['build-js', ], 'watch')();
});
gulp.task('release', function () {
return sequence('build-js', 'dist-min')();
});
gulp.task('watch', function () {
gulp.watch('src/*.js', ['build-js']);
});
gulp.task('build-js', function () {
return gulp.src('src/*.js')
.pipe(concat('formtools.js'))
.pipe(plumber({
errorHandler: function (error) {
console.log(error.plugin, error.message, '\n');
return this.emit('end');
}
}))
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError())
.pipe(gulp.dest('dist/latest/'));
});
gulp.task('dist-min', function () {
return gulp.src('dist/latest/formtools.js')
.pipe(rename({
extname: '.min.js'
}))
.pipe(size({title: 'PRE-MINIFY'}))
.pipe(uglify({ mangle:true }))
.pipe(size({title: 'POST-MINIFY'}))
.pipe(gulp.dest('dist/latest'));
});