Here is my minification gulp task:
var gulp = require('gulp'),
useref = require('gulp-useref'),
gulpif = require('gulp-if'),
uglify = require('gulp-uglify'),
minifyCss = require('gulp-minify-css'),
ngmin = require('gulp-ngmin'),
ngAnnotate = require('gulp-ng-annotate');
gulp.task('minifyAll', function () {
return gulp.src('app/*.html')
.pipe(useref())
.pipe(gulpif('*.js', uglify(ngAnnotate())))
.pipe(gulpif('*.css', minifyCss()))
.pipe(gulp.dest('dist'));
});
In case of js-file I want to move it through ng-annotate first and uglify then. I am new to gulp, that's why I don't know how to do it correctly.
I found solution. Maybe it is not the best, but at least it works.
gulp.task('minifyAll', function () {
return gulp.src('app/*.html')
.pipe(useref())
.pipe(gulpif('*.js', ngAnnotate()))
.pipe(gulpif('*.js', uglify()))
.pipe(gulpif('*.css', minifyCss()))
.pipe(gulp.dest('dist'));
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.