标签:比较 div ref ebs tor on() blog bool function
本文是参考npm社区的gulp-connect。
这个gulp-connect启动服务器(并能时时同步)。
赞助者是JetBrains(好像是webstorm的编辑器开发者公司)。
npm install --save-dev gulp-connect
var gulp = require(‘gulp‘),
connect = require(‘gulp-connect‘);
gulp.task(‘connect‘, function() {
connect.server();
});
gulp.task(‘default‘, [‘connect‘]);
var gulp = require(‘gulp‘),
connect = require(‘gulp-connect‘);
gulp.task(‘connect‘, function() {
connect.server({
root: ‘app‘,
livereload: true
});
});
gulp.task(‘html‘, function () {
gulp.src(‘./app/*.html‘)
.pipe(connect.reload());
});
gulp.task(‘watch‘, function () {
gulp.watch([‘./app/*.html‘], [‘html‘]);
});
gulp.task(‘default‘, [‘connect‘, ‘watch‘]);
gulp.task(‘jenkins-tests‘, function() {
connect.server({
port: 8888
});
// run some headless tests with phantomjs
// when process exits:
connect.serverClose();
});
var gulp = require(‘gulp‘),
stylus = require(‘gulp-stylus‘),
connect = require(‘gulp-connect‘);
gulp.task(‘connectDev‘, function () {
connect.server({
name: ‘Dev App‘,
root: [‘app‘, ‘tmp‘],
port: 8000,
livereload: true
});
});
gulp.task(‘connectDist‘, function () {
connect.server({
name: ‘Dist App‘,
root: ‘dist‘,
port: 8001,
livereload: true
});
});
gulp.task(‘html‘, function () {
gulp.src(‘./app/*.html‘)
.pipe(connect.reload());
});
gulp.task(‘stylus‘, function () {
gulp.src(‘./app/stylus/*.styl‘)
.pipe(stylus())
.pipe(gulp.dest(‘./app/css‘))
.pipe(connect.reload());
});
gulp.task(‘watch‘, function () {
gulp.watch([‘./app/*.html‘], [‘html‘]);
gulp.watch([‘./app/stylus/*.styl‘], [‘stylus‘]);
});
gulp.task(‘default‘, [‘connectDist‘, ‘connectDev‘, ‘watch‘]);
如果http2的安装包已经安装,你用https联动到gulp connect插件,然后http2将成为首选。
api参数比较多,这里说写一些常用的
1、option.root
str array 启动服务器的目录
2、option.port
服务器的端口,默认是3000
3、options.livereload
boolean, 是否开启时时同步,默认是false,通常是开启的
其他参数和localhost的属性很像,不再累赘(点击获取详情)
标签:比较 div ref ebs tor on() blog bool function
原文地址:http://www.cnblogs.com/liangcheng11/p/6956242.html