# 建议先走vue优化三步曲
# 找到根目录下 config 文件夹下的 index.js
把 assetsPublicPath: '/'
修改成 assetsPublicPath: './'
build: {
// Template for index.html
index: path.resolve(__dirname, '../dist/index.html'),
// Paths
assetsRoot: path.resolve(__dirname, '../dist'),
assetsSubDirectory: 'static',
assetsPublicPath: './',
...
}
# 打包
npm run build
# 项目会新增一个 dist 文件夹,这就是我们打包好的项目
— .idea
— build
— config
— dist
— node_modules
— src
— static
— .babelrc
— .editorconfig
— .gitignore
— .postcssrc.js
— index.html
— package.json
— package-lock.json
— README.md
# 部署到tomcat
- 把 dist 文件夹放到 Tomcat 的 webapps 文件夹下
- 启动Tomcat,访问 http://localhost:8080/dist
dist 文件夹名字可自行修改