// 服务器
gulp.task(‘server‘, function() {
var BASEURL = command==‘watchapi‘?‘https://api.bianla.cn/‘:"https://dev.bianla.cn/";
var BASEURL2 = command==‘watchapi‘?‘https://apibbs.bianla.cn/‘:"https://devbbs.bianla.cn/";
browser.server({
host: getIPAdress, //地址,可不写,不写的话,默认localhost
// port: 8000, //端口号,可不写,默认8000
root: `${pathObj.path}/test`, //当前项目主目录
livereload: true, //自动刷新
middleware:function(connect,opt){
return [proxy(‘/APIBIANLA‘,{
target:BASEURL,
changeOrigin:true,
pathRewrite:{"/APIBIANLA" :BASEURL}
}),
proxy(‘/APIBBSBIANLA‘,{
target:BASEURL2,
changeOrigin:true,
pathRewrite:{"/APIBBSBIANLA" :BASEURL2}
})]
}
});
});
3.
gulp.task(‘watch‘,[‘server‘],()=>{
gulp.watch(`${pathObj.path}/dev/lib/*.js`,[‘js‘]);
gulp.watch([`${path.resolve("../")}/assets/js/*.js`,`${path.resolve("../")}/assets/styles/*.less`],[‘common‘]);
gulp.watch(`${pathObj.path}/dev/styles/*.less`,[‘less‘]);
gulp.watch([`${pathObj.path}/dev/*.html`,`${pathObj.path}/dev/template/**/*.html`],[‘html‘]);
});