Gulp 项目简单构建,自动刷新页面

/**
 * Created by 1900 on 12/18/2015.
 */
var plugins={
    fs:require("fs"),
    gulp:require("gulp"),
    uglify:require("gulp-uglify"),
    connect :require('gulp-connect'),
    notify:require("gulp-notify")
}
var gulp = plugins.gulp;
//uglify 表示压缩
//dest表示部署
gulp.task('js', function () {
    gulp.src('src/*.js')
        .pipe(plugins.uglify())
        .pipe(gulp.dest('dist'))
        .pipe(plugins.connect.reload())
        .pipe(plugins.notify({message:"js deploy"}))
});
gulp.task('html', function () {
    gulp.src('src/*.html')
        .pipe(gulp.dest('dist'))
        .pipe(plugins.connect.reload())
        .pipe(plugins.notify({message:"html deploy"}))
});
gulp.task('connect', function () {
    plugins.connect.server({
        root:"dist",
        livereload:true
    });
});
gulp.task("watch",function()
{
    gulp.watch("src/*.js",["js"]);
    gulp.watch("src/*.html",["html"]);
})

gulp.task('default', function () {
    gulp.run("connect");
    gulp.run("watch");
});

gulpfile.js内容如上

项目结构图如下

原文地址:https://www.cnblogs.com/Zoes/p/5127247.html