forked from stamen/legend-layer-menu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGulpfile.js
70 lines (63 loc) · 1.63 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
69
70
var gulp = require('gulp'),
watch = require('gulp-watch'),
rename = require('gulp-rename'),
copy = require('gulp-copy'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
sourcemaps = require('gulp-sourcemaps'),
wrap = require('gulp-wrap'),
run = require("gulp-run"),
fs = require('fs');
var paths = {
js : './src/*.js',
dist : './dist'
};
//
// Check quality of Javascript
// warn if errors or style problems are found
//
gulp.task('lint', function() {
return gulp.src(paths.js)
.pipe(jshint({
"predef" : ["module", "define"],
"expr" : true,
"globalstrict" : true
}))
.pipe(jshint.reporter('jshint-stylish'));
});
gulp.task('uglify', function() {
gulp.src(paths.js)
.pipe(sourcemaps.init())
.pipe(uglify().on("error", function(e) {
console.log("Uglify error:\x07",e.message, " on line: ", e.lineNumber);
return this.end();
}))
.pipe(rename({extname: ".min.js"}))
.pipe(sourcemaps.write("./")) //Write a sourcemap for browser debugging
.pipe(gulp.dest(paths.dist))
});
//
// Generate CSS from Sass and move it
// to the public directory
//
//
gulp.task("sass", function () {
fs.readdirSync("./src").forEach(function() {
run("sass --update src/:./src", {}).exec();
});
});
//
// Run all default tasks
//
gulp.task('default',function(){
gulp.start('lint');
gulp.start('uglify');
gulp.start('sass');
});
//
// Watch directories For Changes
//
gulp.task('watch', function() {
gulp.watch('src/*.*', ['lint','uglify','sass']);
console.log('watching directory:' + 'src/*.*');
});