vue 打包部署

mac2025-10-07  8

启动:npm run dev 部署:打包npm run build:prod(会多一个文件夹dist)

*tomcat部署* 将dist文件夹部署在tomcat的webapps下

http:localhost:8080/dist

*nginx部署* 修改nginx/conf/nginx.conf的server

location / {   try_files $uri $uri/ /index.html; }

将dist文件夹部署在nginx的html下,http:localhost:8080/dist

----------------------------------------------------------------------------------------------

一 如果部署启动后出现空白页,无内容请如下修改

1.修改config/index.js(assetsPublicPath: '/'修改为assetsPublicPath: './')

module.exports = {   dev: {     ...     assetsPublicPath: './',     ...   },   build: {     ...     assetsPublicPath: './',     ...   } }

2. 如果 vue-router mode为 history 模式,使用 nginx,vue-router 为 hash 模式用tomcat(tomcat部署出错时排查修改)

二 如果出现找不到.ttf及.woff文件的错误

修改webpack.base.config中limit: 10000,改为limit: 100000

最新回复(0)