Tyler Scott | b59e6de | 2015-09-18 14:46:30 -0600 | [diff] [blame] | 1 | //Includes |
Tyler Scott | cdfcde8 | 2015-09-14 16:13:29 -0600 | [diff] [blame] | 2 | var gulp = require('gulp'); |
Tyler Scott | e564a5a | 2015-09-16 17:43:33 -0600 | [diff] [blame] | 3 | var minifyHTML = require('gulp-minify-html'); |
| 4 | var minifyCSS = require('gulp-minify-css'); |
| 5 | var sourcemaps = require('gulp-sourcemaps'); |
| 6 | var closure = require('gulp-closure-compiler-service'); |
| 7 | var clean = require('gulp-clean'); |
Tyler Scott | cdfcde8 | 2015-09-14 16:13:29 -0600 | [diff] [blame] | 8 | |
Tyler Scott | b59e6de | 2015-09-18 14:46:30 -0600 | [diff] [blame] | 9 | //Globs |
| 10 | var cssGlob = ['./catalog-dev/css/style.css', './catalog-dev/css/cubeLoader.css']; |
| 11 | var jsGlob = './catalog-dev/js/*.js'; |
| 12 | var htmlGlob = './catalog-dev/index.html'; |
| 13 | |
Tyler Scott | e564a5a | 2015-09-16 17:43:33 -0600 | [diff] [blame] | 14 | gulp.task('minify-html', function() { |
| 15 | |
Tyler Scott | b59e6de | 2015-09-18 14:46:30 -0600 | [diff] [blame] | 16 | return gulp.src(htmlGlob) |
Tyler Scott | e564a5a | 2015-09-16 17:43:33 -0600 | [diff] [blame] | 17 | .pipe(minifyHTML()) |
| 18 | .pipe(gulp.dest('./catalog/')); |
Tyler Scott | cdfcde8 | 2015-09-14 16:13:29 -0600 | [diff] [blame] | 19 | |
| 20 | }); |
| 21 | |
Tyler Scott | e564a5a | 2015-09-16 17:43:33 -0600 | [diff] [blame] | 22 | gulp.task('minify-js', function() { |
| 23 | |
Tyler Scott | b59e6de | 2015-09-18 14:46:30 -0600 | [diff] [blame] | 24 | return gulp.src(jsGlob, {base: 'catalog-dev'}) |
Tyler Scott | e564a5a | 2015-09-16 17:43:33 -0600 | [diff] [blame] | 25 | .pipe(sourcemaps.init()) |
| 26 | .pipe(closure()) |
Tyler Scott | b59e6de | 2015-09-18 14:46:30 -0600 | [diff] [blame] | 27 | .pipe(sourcemaps.write({sourceRoot: '/catalog-dev', includeContent: false})) |
| 28 | .pipe(gulp.dest('./catalog')); |
Tyler Scott | e564a5a | 2015-09-16 17:43:33 -0600 | [diff] [blame] | 29 | |
| 30 | }); |
| 31 | |
| 32 | gulp.task('minify-css', function() { |
| 33 | |
Tyler Scott | b59e6de | 2015-09-18 14:46:30 -0600 | [diff] [blame] | 34 | return gulp.src(cssGlob, {base: 'catalog-dev'}) |
Tyler Scott | e564a5a | 2015-09-16 17:43:33 -0600 | [diff] [blame] | 35 | .pipe(sourcemaps.init()) |
| 36 | .pipe(minifyCSS()) |
Tyler Scott | b59e6de | 2015-09-18 14:46:30 -0600 | [diff] [blame] | 37 | .pipe(sourcemaps.write({sourceRoot: '/catalog-dev', includeContent: false})) |
| 38 | .pipe(gulp.dest('./catalog')); |
Tyler Scott | e564a5a | 2015-09-16 17:43:33 -0600 | [diff] [blame] | 39 | |
| 40 | }); |
| 41 | |
| 42 | gulp.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 | |
| 52 | gulp.task('clean', function(){ |
| 53 | |
| 54 | return gulp.src('./catalog', {read: false}) |
| 55 | .pipe(clean()); |
| 56 | |
| 57 | }); |
| 58 | |
Tyler Scott | b59e6de | 2015-09-18 14:46:30 -0600 | [diff] [blame] | 59 | gulp.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 Scott | e564a5a | 2015-09-16 17:43:33 -0600 | [diff] [blame] | 68 | gulp.task('default', ['minify-html', 'minify-css', 'minify-js', 'copy']); |
| 69 | |