简单介绍下ng-annotate这个项目,这个项目正好提供了gulp的插件。
gulp配置文件:
var gulp = require(‘gulp‘);
var ngAnnotate = require(‘gulp-ng-annotate‘); //这个
var gutil = require(‘gulp-util‘);
var bower = require(‘bower‘);
var uglify = require(‘gulp-uglify‘);
var concat = require(‘gulp-concat‘);
var minifyCss = require(‘gulp-minify-css‘);
var rename = require(‘gulp-rename‘);
var sh = require(‘shelljs‘);
var ngmin = require(‘gulp-ngmin‘); //这个
var stripDebug = require(‘gulp-strip-debug‘);
gulp.task(‘minify‘, function() {
return gulp.src([‘js/appService.js‘,‘js/app.js‘]) //注意,此处特意如此,避免顺序导致的问题
.pipe(ngAnnotate())
.pipe(ngmin({dynamic: false})) //这个
.pipe(stripDebug())
.pipe(uglify({outSourceMap: false})) //海鸥注意这里的outSourceMap 一定添加
.pipe(concat(‘all.min.js‘))
.pipe(gulp.dest(‘js/‘))
});
时间: 2024-10-08 05:08:32