From 13f20a549542848420fbc2ba9073b6ed23f41906 Mon Sep 17 00:00:00 2001 From: Amio Date: Wed, 12 Mar 2014 13:03:32 +0800 Subject: [PATCH] =?UTF-8?q?WA=E5=BC=80=E5=8F=91=E7=8E=AF=E5=A2=83=EF=BC=9A?= =?UTF-8?q?=E6=95=B4=E7=90=86=20gulp=20=E6=8F=92=E4=BB=B6=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gulpfile.js | 44 ++++++++++++++++++-------------------------- package.json | 8 +++----- 2 files changed, 21 insertions(+), 31 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index b04b44b..211d254 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -21,7 +21,7 @@ var path = require('path'); var LIVERELOAD_PORT = 35729; -function createServers (root, port, lrport) { +function createServers(root, port, lrport) { // App Server var app = express(); @@ -76,44 +76,36 @@ gulp.task('server:dist', function () { //var sass = require('gulp-ruby-sass'); //var jshint = require('gulp-jshint'); -var usemin = require('gulp-usemin'); -var uglify = require('gulp-uglify'); -var minifyhtml = require('gulp-minify-html'); -var minifycss = require('gulp-minify-css'); -var imagemin = require('gulp-imagemin'); -var clean = require('gulp-clean'); -var rev = require('gulp-rev'); - gulp.task('usemin', function () { gulp.src('./app/*.html') - .pipe(usemin({ - css: [minifycss(), rev()], - js: [uglify(), rev()], - html: [minifyhtml({empty: true})] - })) - .pipe(gulp.dest(BUILD_ROOT)); + .pipe($.usemin({ + css: [$.minifyCss(), $.rev()], + js: [$.uglify(), $.rev()], + html: [$.minifyHtml({empty: true})] + })) + .pipe(gulp.dest(BUILD_ROOT)); }); gulp.task('imagemin', function () { - gulp.src(SOURCE_ROOT + '/images/*.*', {base: SOURCE_ROOT}) - .pipe(imagemin()) - .pipe(gulp.dest(BUILD_ROOT)); + gulp.src(SOURCE_ROOT + '/images/*.*') + .pipe($.imagemin()) + .pipe(gulp.dest(BUILD_ROOT + '/images/')); }); gulp.task('copy', function () { gulp.src([ - '!' + SOURCE_ROOT + '/*.html', - SOURCE_ROOT + '/*.*', - SOURCE_ROOT + '/font/**/*', - SOURCE_ROOT + '/partials/**/*', - SOURCE_ROOT + '/templates/**/*' - ], {base: SOURCE_ROOT}) - .pipe(gulp.dest(BUILD_ROOT)); + '!' + SOURCE_ROOT + '/*.html', + SOURCE_ROOT + '/*.*', + SOURCE_ROOT + '/font/**/*', + SOURCE_ROOT + '/partials/**/*', + SOURCE_ROOT + '/templates/**/*' + ], { base: SOURCE_ROOT }) + .pipe(gulp.dest(BUILD_ROOT)); }); gulp.task('clean', function () { return gulp.src([BUILD_ROOT], {read: false}) - .pipe(clean()); + .pipe($.clean()); }); gulp.task('build', ['clean'], function () { diff --git a/package.json b/package.json index e30a54c..2e874ce 100644 --- a/package.json +++ b/package.json @@ -3,18 +3,16 @@ "version": "0.0.2", "dependencies": {}, "devDependencies": { + "gulp": "~3.5.0", + "gulp-load-plugins": "~0.3.0", "gulp-usemin": "~0.3.1", "gulp-uglify": "~0.2.1", "gulp-minify-css": "~0.3.0", "gulp-minify-html": "~0.1.0", "gulp-rev": "~0.2.1", - - "gulp": "~3.5.0", - "gulp-load-plugins": "~0.3.0", "gulp-util": "~2.2.9", "gulp-connect": "~1.0.7", "gulp-exec": "~1.0.4", - "gulp-autoprefixer": "~0.0.6", "gulp-jshint": "~1.4.0", "gulp-imagemin": "~0.1.5", @@ -23,7 +21,7 @@ "gulp-size": "~0.1.2", "gulp-useref": "~0.1.2", "gulp-bundle": "~0.2.0", - + "gulp-ng-html2js": "~0.1.6", "express": "*", "tiny-lr": "*", "connect-livereload": "*",