Last active
November 30, 2017 17:52
-
-
Save sijintv/7e0f6bcbe3c219e30e06e3f8ffd1dd59 to your computer and use it in GitHub Desktop.
Gulp Tasks for watching building and uglying AngularJS project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var gulp = require('gulp'), | |
concat = require('gulp-continuous-concat'), | |
uglifyjs = require('gulp-uglify'); | |
uglifycss = require('gulp-clean-css'); | |
htmlmin = require('gulp-html-minifier'); | |
ngAnnotate = require('gulp-ng-annotate'); | |
watch = require('gulp-watch'); | |
gulp.task('js', function(){ | |
return gulp.src(['js/app.js', 'js/config.js', 'js/directives.js', 'js/controllers.js']) | |
.pipe(watch(['js/app.js', 'js/config.js', 'js/directives.js', 'js/controllers.js'])) | |
.pipe(concat('app.js')) | |
.pipe(ngAnnotate()) | |
.pipe(uglifyjs()) | |
.pipe(gulp.dest('dist')) | |
}); | |
gulp.task('css', function(){ | |
return gulp.src(['css/style.css', 'css/animate.css']) | |
.pipe(watch(['css/style.css', 'css/animate.css'])) | |
.pipe(concat('app.css')) | |
.pipe(uglifycss({level: {1: {specialComments: 0}}})) | |
.pipe(gulp.dest('dist')) | |
}); | |
gulp.task('img', function(){ | |
return gulp.src('img/**/*') | |
.pipe(watch('img/**/*')) | |
.pipe(gulp.dest('dist/img')); | |
}); | |
gulp.task('view', function(){ | |
return gulp.src('views/**/*.html') | |
.pipe(watch('views/**/*.html')) | |
.pipe(htmlmin({collapseWhitespace: true, removeComments: true})) | |
.pipe(gulp.dest('dist/views')); | |
}); | |
gulp.task('index', function(){ | |
return gulp.src('index.html') | |
.pipe(watch('index.html')) | |
.pipe(htmlmin({collapseWhitespace: true, removeComments: true, collapseInlineTagWhitespace: true})) | |
.pipe(gulp.dest('dist')); | |
}); | |
gulp.task('other', function(){ | |
return gulp.src(['favicon.ico', 'robots.txt']) | |
.pipe(watch(['favicon.ico', 'robots.txt'])) | |
.pipe(gulp.dest('dist')); | |
}); | |
gulp.task('process',['js', 'css', 'img', 'view', 'index', 'other']); | |
gulp.task('default', ['process']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment