在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):narirou/gulp-develop-server开源软件地址(OpenSource Url):https://github.com/narirou/gulp-develop-server开源编程语言(OpenSource Language):JavaScript 100.0%开源软件介绍(OpenSource Introduction):gulp-develop-server
gulp-develop-server is a development assistant for node.js server that runs the process and automatically restarts it when a file is modified. installationnpm install gulp-develop-server --save-dev usagevar gulp = require( 'gulp' ),
server = require( 'gulp-develop-server' );
// run server
gulp.task( 'server:start', function() {
server.listen( { path: './app.js' } );
});
// restart server if app.js changed
gulp.task( 'server:restart', function() {
gulp.watch( [ './app.js' ], server.restart );
}); api###server.listen( options[, callback] ) options {Object}
callback( error ) ###server.restart( [callback] ) / server.changed( [callback] ) callback( error ) ###server( [options] ) Create a ###server.kill( [signal, callback] ) Send kill signal to the server process. ###server.reset( [signal, callback] ) Send kill signal to the server process and reset the options to default. more examples####with gulp-livereload: var gulp = require( 'gulp' ),
server = require( 'gulp-develop-server' ),
livereload = require( 'gulp-livereload' );
var options = {
path: './apps/app.js'
};
var serverFiles = [
'./apps/app.js',
'./routes/*.js'
];
gulp.task( 'server:start', function() {
server.listen( options, livereload.listen );
});
// If server scripts change, restart the server and then livereload.
gulp.task( 'default', [ 'server:start' ], function() {
function restart( file ) {
server.changed( function( error ) {
if( ! error ) livereload.changed( file.path );
});
}
gulp.watch( serverFiles ).on( 'change', restart );
}); ####with BrowserSync: var gulp = require( 'gulp' ),
server = require( 'gulp-develop-server' ),
bs = require( 'browser-sync' );
var options = {
server: {
path: './apps/app.js',
execArgv: [ '--harmony' ]
},
bs: {
proxy: 'http://localhost:3000'
}
};
var serverFiles = [
'./apps/app.js',
'./routes/*.js'
];
gulp.task( 'server:start', function() {
server.listen( options.server, function( error ) {
if( ! error ) bs( options.bs );
});
});
// If server scripts change, restart the server and then browser-reload.
gulp.task( 'server:restart', function() {
server.restart( function( error ) {
if( ! error ) bs.reload();
});
});
gulp.task( 'default', [ 'server:start' ], function() {
gulp.watch( serverFiles, [ 'server:restart' ] )
}); ####use as a stream: var gulp = require( 'gulp' ),
server = require( 'gulp-develop-server' ),
bs = require( 'browser-sync' ),
coffee = require( 'gulp-coffee' );
var options = {
server: {
path: './apps/app.js',
execArgv: [ '--harmony' ]
},
bs: {
proxy: 'http://localhost:3000'
}
};
var serverCoffee = [
'./src/*.coffee'
];
gulp.task( 'server:start', function() {
server.listen( options.server, function( error ) {
if( ! error ) bs( options.bs );
});
});
// If server side's coffee files change, compile these files,
// restart the server and then browser-reload.
gulp.task( 'server:restart', function() {
gulp.src( serverCoffee )
.pipe( coffee() )
.pipe( gulp.dest( './apps' ) )
.pipe( server() )
.pipe( bs.reload({ stream: true }) );
});
gulp.task( 'default', [ 'server:start' ], function() {
gulp.watch( serverCoffee, [ 'server:restart' ] );
}); thanks@pronebird |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论