blob: 585a7918c075a22e6b4001a91cc620f5696aec04 [file] [log] [blame]
Tyler Scottb59e6de2015-09-18 14:46:30 -06001//Includes
Tyler Scottcdfcde82015-09-14 16:13:29 -06002var gulp = require('gulp');
Tyler Scotte564a5a2015-09-16 17:43:33 -06003var minifyHTML = require('gulp-minify-html');
4var minifyCSS = require('gulp-minify-css');
5var sourcemaps = require('gulp-sourcemaps');
6var closure = require('gulp-closure-compiler-service');
7var clean = require('gulp-clean');
Tyler Scottcdfcde82015-09-14 16:13:29 -06008
Tyler Scottb59e6de2015-09-18 14:46:30 -06009//Globs
10var cssGlob = ['./catalog-dev/css/style.css', './catalog-dev/css/cubeLoader.css'];
11var jsGlob = './catalog-dev/js/*.js';
12var htmlGlob = './catalog-dev/index.html';
13
Tyler Scotte564a5a2015-09-16 17:43:33 -060014gulp.task('minify-html', function() {
15
Tyler Scottb59e6de2015-09-18 14:46:30 -060016 return gulp.src(htmlGlob)
Tyler Scotte564a5a2015-09-16 17:43:33 -060017 .pipe(minifyHTML())
18 .pipe(gulp.dest('./catalog/'));
Tyler Scottcdfcde82015-09-14 16:13:29 -060019
20});
21
Tyler Scotte564a5a2015-09-16 17:43:33 -060022gulp.task('minify-js', function() {
23
Tyler Scottb59e6de2015-09-18 14:46:30 -060024 return gulp.src(jsGlob, {base: 'catalog-dev'})
Tyler Scotte564a5a2015-09-16 17:43:33 -060025 .pipe(sourcemaps.init())
26 .pipe(closure())
Tyler Scottb59e6de2015-09-18 14:46:30 -060027 .pipe(sourcemaps.write({sourceRoot: '/catalog-dev', includeContent: false}))
28 .pipe(gulp.dest('./catalog'));
Tyler Scotte564a5a2015-09-16 17:43:33 -060029
30});
31
32gulp.task('minify-css', function() {
33
Tyler Scottb59e6de2015-09-18 14:46:30 -060034 return gulp.src(cssGlob, {base: 'catalog-dev'})
Tyler Scotte564a5a2015-09-16 17:43:33 -060035 .pipe(sourcemaps.init())
36 .pipe(minifyCSS())
Tyler Scottb59e6de2015-09-18 14:46:30 -060037 .pipe(sourcemaps.write({sourceRoot: '/catalog-dev', includeContent: false}))
38 .pipe(gulp.dest('./catalog'));
Tyler Scotte564a5a2015-09-16 17:43:33 -060039
40});
41
42gulp.task('copy', function() {
43
44 gulp.src('./catalog-dev/config.json')
45 .pipe(gulp.dest('./catalog'));
46
47 gulp.src('./catalog-dev/css/*.min.css')
48 .pipe(gulp.dest('./catalog/css'));
49
50});
51
52gulp.task('clean', function(){
53
54 return gulp.src('./catalog', {read: false})
55 .pipe(clean());
56
57});
58
Tyler Scottb59e6de2015-09-18 14:46:30 -060059gulp.task('watch', ['default'], function(){
60
61 gulp.watch(cssGlob, ['minify-css']);
62 gulp.watch(jsGlob, ['minify-js']);
63 gulp.watch(htmlGlob, ['minify-html']);
64 gulp.watch(['./catalog-dev/config.json', './catalog-dev/css/*.min.css'], ['copy']);
65
66});
67
Tyler Scotte564a5a2015-09-16 17:43:33 -060068gulp.task('default', ['minify-html', 'minify-css', 'minify-js', 'copy']);
69