vue 打包用history

ng

 vue.config.js配置

module.exports = {
	// 是否开启cssSourceMap
	productionSourceMap: true,
	//build输出目录
	outputDir:"h5",
	//静态资源目录(js, css, img)
	assetsDir:"static",
	filenameHashing:false,
	// 设置打包文件路径
	publicPath: process.env.NODE_ENV === 'production' ? '././' : '/',
	devServer: {
		// host:'192.168.1.16',
		// port:8080,
		proxy: {
			"/server": {
				//API服务器的地址
				target: "http://127.0.0.1:8081/",
				logLevel:'debug',
				// 是否跨域,虚拟的站点需要更管origin
				changeOrigin: true,
				pathRewrite: {
					//重写路径
					"^/server": "/server"
				}
			},
		},
	},
}

 nginx配置

  worker_processes  1;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;

    keepalive_timeout  65;

    server_names_hash_max_size 512;
    server_names_hash_bucket_size 128;
	
	server {
        //访问端口
	    listen       7078;
        //访问地址
		server_name  127.0.0.1;
        //前端配置路径
	    location / {
			root D:/h5;
			index index.html;
			try_files $uri $uri/ @router;
	    }
        //后端服务器请求地址
		location ^~/prod-api-h5/{
			proxy_pass http://127.0.0.1:8081/;
			proxy_set_header Host $host:$server_port;
		}
		location @router {
			rewrite ^.*$ /index.html last; 
		}
		error_page 500 502 504 /50x.html;
		location =/50x.html{
			root html;
		}
	}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值