前端自动化构建工具 - gulp - 02 - webserver环境
前言
配置一个可实时预览的环境
安装
1
npm install --save-dev gulp-live-server
配置
1
2
3
4
5
6
7
var gulp = require('gulp');
var webserver = require('gulp-webserver');
gulp.task('webserver', function() {
var server = gls.static('release/dist', 8080);
server.start();
});
release/dist 请指向你的发布目录
运行
- 输入
1
gulp webserver
- 输出
1
2
3
4
5
[14:31:06] Using gulpfile ~/gulpfile.js
[14:31:06] Starting 'webserver'...
[14:31:06] Finished 'webserver' after 10 ms
livereload[tiny-lr] listening on 35729 ...
folder "release/dist" serving at http://localhost:8080
参考文
https://www.npmjs.com/package/gulp-live-server