The gulp front-end automation tool is a stream-based automated construction tool;
installation steps:
- cnpm install gulp -g //install gulp globally
- cnpm init //Initialize the package.json file
- gulpfile.js //Create gulpfile.js manually
- cnpm install [email protected] --save-dev //Install gulp and other plug-ins locally
- 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 //自动打开
}));
})