var gulp = require('gulp');
var gulpServer = require('gulp-webserver');
const { createProxyMiddleware } = require('http-proxy-middleware');
const { src, series, dest, watch } = require("gulp");


function startServer() {
    return src("./src")
        .pipe(gulpServer({
            port: 8008,//端口号
            host: "127.0.0.1",
            livereload: true,//是否热更新
            open: '/sys',//(boolean\string)是否打开浏览器，可以指定默认路径
            path:'/sys',//(string)网络服务器的路径
            middleware:[
                createProxyMiddleware("/api",{
                    //pathFilter:"/api",//高版本的gulp在此配置
                    target:"http://127.0.0.1:8066/",//本地开发环境
                    //target:"http://测试环境/",
                    //target:"http://生产环境/",
                    changeOrigin:true,//是否跨域
                    ws: true, // 是否代理websockets
                    pathRewrite:{
                        '^/api':''
                    }
                })
            ]

        }))
}

exports.default = startServer;


