Vue3.0项目 Nginx发布配置

1,129 阅读1分钟

1.vue-cli打包

修改publicPath参数为:'./'

//vue.config.js
const path = require('path')
module.exports = {
    //选项
    chainWebpack: config => {
        config.resolve.alias
        .set('@', path.resolve(__dirname, 'src'))
        .set('components',path.resolve(__dirname,'src/components'))
        .set('views', path.resolve(__dirname, 'src/views'));
    },
    publicPath: './'
}

运行命令: npm run bulid

2.将生成的dist目录拷贝到服务器

3.服务器运行serve

node install -g serve
serve -s -p 5000

4.配置Nginx

server {
        listen       portNumber;
        server_name  your ip address;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location  /aaa/ {
            proxy_pass http://127.0.0.1:5000/;
        }
    }

5.Nginx运行

start nginx