forked from danmichaelo/croptool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
55 lines (48 loc) · 1.73 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
/* Dependencies
------------------------------------- */
var gulp = require('gulp-help')(require('gulp'));
var jshint = require('gulp-jshint');
var stylish = require('jshint-stylish');
var uglify = require('gulp-uglify');
var csso = require('gulp-csso');
var sourcemaps = require('gulp-sourcemaps');
var rev = require('gulp-rev');
var revReplace = require('gulp-rev-replace');
var filter = require('gulp-filter');
var useref = require('gulp-useref');
/* Variables and paths
------------------------------------- */
var paths = {
build: 'public_html/',
index: 'src/index.html',
};
/* Tasks
------------------------------------- */
gulp.task('jshint', 'Lints all javascript files', [], function() {
return gulp.src(paths.scripts)
.pipe(jshint())
.pipe(jshint.reporter(stylish))
;
});
gulp.task('build', 'Builds the app', [], function() {
var jsFilter = filter('**/*.js', { restore: true });
var cssFilter = filter('**/*.css', { restore: true });
var notIndexHtmlFilter = filter(['**/*', '!**/index.html'], { restore: true });
return gulp.src(paths.index)
.pipe(useref({ searchPath: '.' }))
.pipe(jsFilter)
.pipe(uglify()) // Minify any javascript sources
.pipe(jsFilter.restore)
.pipe(cssFilter)
.pipe(csso()) // Minify any CSS sources
.pipe(cssFilter.restore)
.pipe(notIndexHtmlFilter)
.pipe(rev()) // Rename the concatenated files (but not index.html)
.pipe(notIndexHtmlFilter.restore)
.pipe(revReplace()) // Substitute in new filenames
.pipe(gulp.dest(paths.build))
;
});
gulp.task('watch', 'Re-builds the app on changes', ['build'], function () {
gulp.watch(['src/js/**/*.js', 'src/css/**/*.css', 'src/index.html'], ['build']);
});