发布到tomcat上
在vue项目打包的时候,
- config/index.js里面的assetsPublicPath写成 '/项目名/'(assetsPublicPath: '/项目名/'),
- src/router/index.js里面加上base: '/项目名/',
export default new Router({
mode : 'history',
base: '/项目名/',
...
})
,打包好之后把dist里面的东西上传到tomcat的webapps下的对应的项目文件夹里就行了。
发布到nginx
打包是同样的操作,nginx配置:
location /channel { //对应打包的项目名
root /usr/html/; //channel文件夹之上的文件路径,/usr/html/channel/路径下是打包后dist文件夹里的东西
index index.html;
try_files $uri $uri/ /channel/index.html; //处理404或者空白页面,转发到channel的index页面
}