标签:desc ota path pre auth pat main blog file
var gulp = require(‘gulp‘), minifycss = require(‘gulp-minify-css‘), minifyhtml = require("gulp-minify-html"), /* jshint = require(‘gulp-jshint‘),*/ uglify = require(‘gulp-uglify‘), rename = require(‘gulp-rename‘), concat = require(‘gulp-concat‘); var rev = require(‘gulp-rev‘); //- 对文件名加MD5后缀 var revCollector = require(‘gulp-rev-collector‘); //- 路径替换 var ngAnnotate = require(‘gulp-ng-annotate‘); var useref = require(‘gulp-useref‘); var revReplace = require(‘gulp-rev-replace‘); var clean = require(‘gulp-clean‘); var amdOptimize = require(‘gulp-amd-optimizer‘); var srcPath = { html: ‘app1‘, css: ‘app1/css‘, script: ‘app1/js‘, image: ‘app1/images‘ }; var destPath = { html: ‘app‘, css: ‘app/css‘, script: ‘app/js‘, image: ‘app/images‘ }; gulp.task("clean", function () { return gulp.src([‘app‘,‘dist‘,‘json‘]) .pipe(clean()); }) // Styles任务 gulp.task(‘styles‘, function () { //编译sass return gulp.src(srcPath.css + ‘/*.css‘) //保存未压缩文件到我们指定的目录下面 // .pipe(gulp.dest(theDst)) //给文件添加.min后缀 // .pipe(rev()) // .pipe(rename({ suffix: ‘.min‘ })) //压缩样式文件 .pipe(minifycss()) //输出压缩文件到指定目录 .pipe(gulp.dest(destPath.css)) // .pipe(rev.manifest({merge: true})) //- 生成一个rev-manifest.json .pipe(gulp.dest(‘./json‘)); //- 将 rev-manifest.json 保存到 rev 目录内 }); gulp.task(‘minify‘, function () { var manifest = gulp.src("json/*.json"); return gulp.src([srcPath.script + ‘/**/*.js‘]) //注意,此处特意如此,避免顺序导致的问题 .pipe(ngAnnotate()) // .pipe(rev()) .pipe(uglify()) .pipe(gulp.dest(destPath.script)) //.pipe(rev.manifest({path: ‘js-manifest.json‘, merge: true})) .pipe(gulp.dest(‘json‘)) }); /*gulp.task(‘app‘, function() { gulp.src([‘dist/json/!*.json‘,‘app.js‘]) .pipe(revCollector()) .pipe(useref({ transformPath: function(filePath) { return filePath.replace(‘js/‘,‘dist/‘) } })) .pipe(gulp.dest(‘app/‘)) });*/ gulp.task(‘app‘,[‘minify‘], function () { var manifest = gulp.src("json/*.json"); gulp.src(destPath.script + ‘/**/*.js‘) .pipe(revReplace({manifest: manifest})) .pipe(gulp.dest(destPath.script)) }); gulp.task(‘main‘,[‘minify‘], function () { var manifest = gulp.src("json/*.json"); gulp.src(destPath.script + ‘/main*.js‘) .pipe(revReplace({manifest: manifest})) .pipe(gulp.dest(destPath.script)) }); gulp.task(‘html‘,[‘minify‘,‘styles‘], function () { var manifest = gulp.src("json/*.json"); gulp.src(srcPath.html + ‘/*.html‘) .pipe(revReplace({manifest: manifest})) .pipe(gulp.dest(destPath.html)) }); // Default task gulp.task(‘default‘, function () { gulp.start(‘styles‘, ‘minify‘, ‘html‘, ‘app‘,‘main‘ ,‘watch‘); }); // Watch gulp.task(‘watch‘, function () { // Watch .js files gulp.watch(srcPath.css + ‘/*.css‘, [‘styles‘]); gulp.watch([srcPath.script + ‘/**/*.js‘, srcPath.script + ‘/*.js‘], [‘minify‘]); //gulp.watch(destPath.script + ‘/**/*.js‘, [‘app‘]); gulp.watch(srcPath.html + ‘/*.html‘, [‘html‘]); });
{ "name": "tejyh", "version": "1.0.0", "main": "gulpfile.js", "dependencies": { "gulp-cli": "^1.3.0" }, "devDependencies": { "gulp": "^3.9.1", "gulp-amd-optimizer": "^0.6.0", "gulp-clean": "^0.3.2", "gulp-concat": "^2.6.0", "gulp-imagemin": "^3.2.0", "gulp-jshint": "^2.0.4", "gulp-less": "^3.3.0", "gulp-livereload": "^3.8.1", "gulp-minify-css": "^1.2.4", "gulp-minify-html": "^1.0.6", "gulp-ng-annotate": "^2.0.0", "gulp-rev": "^7.1.2", "gulp-rev-collector": "^1.1.1", "gulp-rev-replace": "^0.4.3", "gulp-uglify": "^1.5.3", "gulp-useref": "^3.1.2" }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", "license": "ISC", "description": "" }
标签:desc ota path pre auth pat main blog file
原文地址:http://www.cnblogs.com/heyinwangchuan/p/6796295.html