Gulp 设置前端服务器+监控插件
gulpfile.js可以这样进行书写
var gulp = require('gulp'); var livereload = require('gulp-livereload'); var gulpLoadPlugins = require("gulp-load-plugins"); var plugins = gulpLoadPlugins(); var connect = require('gulp-connect'); var pkg = require("./package.json"); /*开发路径定义,分开发目录和生产目录*/ var basePath = pkg.project; var devPath = basePath + "/app/src"; //创建watch任务去检测html文件,其定义了当html改动之后,去调用一个Gulp的Task gulp.task('watch', function () { gulp.watch(['app/**/*.html'], ['html']); }); //使用connect启动一个Web服务器 gulp.task('connect', function () { connect.server({ root: 'app', port:3000, host:'127.0.0.1', livereload: true }); }); gulp.task('html', function () { gulp.src('app/**/*.html') .pipe(connect.reload()); }); //运行Gulp时,默认的Task gulp.task('default', ['connect', 'watch']);
相关推荐
我有一只小松鼠 2020-02-29
MrLiar 2015-11-09
idnochinese 2019-07-01
UndefineOrNull 2019-07-01
liangjielaoshi 2020-06-11
星辰的笔记 2020-07-04
zhongweinan 2020-06-10
jiangfulai 2020-04-18
UndefineOrNull 2020-02-29
UndefineOrNull 2020-03-01
hlihaihong 2020-02-18
UndefineOrNull 2020-02-12
yinuoqingqin 2020-01-13
星辰的笔记 2020-01-13
UndefineOrNull 2020-01-13
hlihaihong 2020-01-13
kaosini 2020-01-12
hlihaihong 2020-01-12
kaosini 2020-01-12