zoukankan      html  css  js  c++  java
  • Gulp简单应用

    1.创建一个工程,在webstorm控制台   cnpm install --save-dev gulp      cnpm install --save-dev gulp-concat        cnpm install --save-dev gulp-minify

    2.环境配置完成后,  创建src文件,放置源  index.html,main.js,和其他的js文件

    3.创建配置文件   gulpfile.js 文件

        

    /**
     * Created by Administrator on 2016/11/10.
     */
    
    const gulp=require("gulp");
    const minify=require("gulp-minify");
    const concat=require("gulp-concat");
    
    const buildDirName = "build";
    gulp.task("copy_html_files",function () {
        return gulp.src("src/*.html").pipe(gulp.dest(buildDirName))
    });
    
    gulp.task("compile_js_files",function () {
        return gulp.src([
            "src/Hello.js",
            "src/Main.js"
        ]).pipe(concat("index.js"))
            .pipe(minify())
            .pipe(gulp.dest(buildDirName));
    
    });
    
    gulp.task("default",["copy_html_files","compile_js_files"],function () {
    
     });
    
    /*自动监测  html 文件的变化*/
    gulp.watch("src/*.html",["copy_html_files"]);
    
    gulp.watch("src/*.js",["compile_js_files"]);
    View Code

    4.在命令行输入 gulp ,自动生成上述代码中的  build  文件夹(包括inde.html,index.js,index-min.js)

    5.运行在build文件夹中的index.html即可

  • 相关阅读:
    PCLint
    pthread_join
    作业过程查找
    sqlcmd (转)
    整合问题
    PATINDEX
    回归Dos操作的快感,进入PowerShell世界 (转)
    Javascript 面向对象编程(一):封装
    理解闭包
    Javascript 面向对象编程(三):非构造函数的继承
  • 原文地址:https://www.cnblogs.com/libo142/p/6056295.html
Copyright © 2011-2022 走看看