-
Notifications
You must be signed in to change notification settings - Fork 431
/
gulpfile.js
68 lines (61 loc) · 1.87 KB
/
gulpfile.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
gifshot Build File
*/
var gulp = require('gulp'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
jshint = require('gulp-jshint'),
requirejs = require('requirejs'),
amdclean = require('amdclean'),
fs = require('fs');
gulp.task('minify', function() {
gulp.src(['src/gifshot.js'])
.pipe(uglify())
.pipe(rename('gifshot.min.js'))
.pipe(gulp.dest('build/'));
});
gulp.task('lint', function() {
gulp.src('src/gifshot.js')
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
gulp.task('clean', function() {
requirejs.optimize({
'findNestedDependencies': true,
'baseUrl': 'src/modules/',
'preserveLicenseComments': false,
'optimize': 'none',
// 'mainConfigFile': 'src/js/app/config/config.js',
'include': ['index'],
'out': 'src/gifshot.js',
'onModuleBundleComplete': function (data) {
var outputFile = data.path;
fs.writeFileSync(outputFile, amdclean.clean({
'filePath': outputFile,
// Will not transform conditional AMD checks - Libraries use this to provide optional AMD support
'transformAMDChecks': false,
// Wraps the library in an IIFE (Immediately Invoked Function Expression)
'wrap': {
'start': ';(function(window, navigator, document, undefined) {',
'end': '}(window, window.navigator, document));'
},
'aggressiveOptimizations': true
}));
}
}, function() {
// console.log('built');
}, function (err) {
console.log(err);
});
});
gulp.task('test', function() {
});
// The default task (called when you run `gulp`)
gulp.task('default', ['clean','lint', 'minify']);
// The watch task
gulp.task('watch', function() {
var watcher = gulp.watch('src/modules/**', ['default']);
watcher.on('change', function(event) {
console.log('File '+event.path+' was '+event.type+', running tasks...');
});
});