Gulp first section to start the service

The gulp front-end automation tool is a stream-based automated construction tool;
installation steps:

  1. cnpm install gulp -g //install gulp globally
  2. cnpm init //Initialize the package.json file
  3. gulpfile.js //Create gulpfile.js manually
  4. cnpm install [email protected] --save-dev //Install gulp and other plug-ins locally
  5. gulp //start

gulpfile.js

var gulp = require('gulp'),
    webserver = require('gulp-webserver');

//定义任务  监听index.html 启动webserver
gulp.task('default',['watch','webserver']);

gulp.task('watch',function(){
    
    
    gulp.watch(['index.html'])
})     

gulp.task('webserver',function(){
    
    
   gulp.src('')   //该任务针对的文件
        .pipe(webserver({
    
        //该任务调用的模块
            path:'/',
            host:'127.0.0.1',
            port:'8082',
            livereload: true, //自动刷新
            direactoryListing:true, //指定目录找到
            open:true   //自动打开
        }));
}) 

Guess you like

Origin blog.csdn.net/weixin_42549581/article/details/99675971