|
| 1 | +var gulp = require('gulp'), |
| 2 | + gulpWatch = require('gulp-watch'), |
| 3 | + del = require('del'), |
| 4 | + argv = process.argv; |
| 5 | + |
| 6 | +/** |
| 7 | + * Ionic Gulp tasks, for more information on each see |
| 8 | + * https://github.com/driftyco/ionic-gulp-tasks |
| 9 | + */ |
| 10 | +var buildWebpack = require('ionic-gulp-webpack-build'); |
| 11 | +var buildSass = require('ionic-gulp-sass-build'); |
| 12 | +var copyHTML = require('ionic-gulp-html-copy'); |
| 13 | +var copyFonts = require('ionic-gulp-fonts-copy'); |
| 14 | + |
| 15 | +gulp.task('watch', ['sass', 'html', 'fonts'], function(){ |
| 16 | + gulpWatch('app/**/*.scss', function(){ gulp.start('sass'); }); |
| 17 | + gulpWatch('app/**/*.html', function(){ gulp.start('html'); }); |
| 18 | + return buildWebpack({ watch: true }); |
| 19 | +}); |
| 20 | +gulp.task('build', ['sass', 'html', 'fonts'], buildWebpack); |
| 21 | +gulp.task('sass', buildSass); |
| 22 | +gulp.task('html', copyHTML); |
| 23 | +gulp.task('fonts', copyFonts); |
| 24 | +gulp.task('clean', function(done){ |
| 25 | + del('www/build', done); |
| 26 | +}); |
| 27 | + |
| 28 | +/** |
| 29 | + * Ionic hooks |
| 30 | + * Add ':before' or ':after' to any Ionic project command name to run the specified |
| 31 | + * tasks before or after the command. |
| 32 | + */ |
| 33 | +gulp.task('serve:before', ['watch']); |
| 34 | +gulp.task('emulate:before', ['build']); |
| 35 | +gulp.task('deploy:before', ['build']); |
| 36 | + |
| 37 | +// we want to 'watch' when livereloading |
| 38 | +var shouldWatch = argv.indexOf('-l') > -1 || argv.indexOf('--livereload') > -1; |
| 39 | +gulp.task('run:before', [shouldWatch ? 'watch' : 'build']); |
0 commit comments