zoukankan      html  css  js  c++  java
  • 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内容如上

    项目结构图如下

  • 相关阅读:
    对学生排序 Exercise07_17
    消除重复 Exercise07_15
    计算gcd Exercise07_14
    随机数选择器 Exercise07_13
    dom4j 学习总结
    jQuery学习总结(二)
    jQuery学习总结(一)
    SQL中Where与Having的区别
    html + css (1)
    struts2+json
  • 原文地址:https://www.cnblogs.com/Zoes/p/5127247.html
Copyright © 2011-2022 走看看