Question: project process, the need to share micro-channel function too, but lost the reason for the signature of the original band was the # vue, so the # removed, the following configuration (here just tomcat):
Examples: vue-cli project to use routing, tomcat as a server, the project folder name myvue
1.npm run build packaged generated build folder to copy the contents of the folder myvue follows:
2.myvue new folder WEB-INF / web.xml added jump path 404 as shown below:
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee/web-app_2_5.xsd" id="scplatform" version="2.5"> <display-name>/</display-name> <error-page> <error-code>404</error-code> <location>/index.html</location> </error-page> </web-app>
3.vue-cli project config / index.js configuration assetsPublicPath: '/ myvue /' project package name
4.vue-cli project src / router / index.js configuration mode: 'history', base: '/ myvue /'
以上vue-cli配置与tomcat部署都ok后,启动tomcat服务器,访问路径项目名myvue,ok可以正确访问了,这里后面不要加index.html,
扩展一下,是不是每次大包项目都要手动添加WEB-INF/web.xml呢。答案不是的,解决方案如下:
1、我的打包配置
new CopyWebpackPlugin([ { from: path.resolve(__dirname, '../static'), to: config.build.assetsSubDirectory, ignore: ['.*'] }, { from: path.resolve(__dirname, '../WEB-INF'), to: 'WEB-INF', ignore: ['.*'] } ])
在项目中添加与static文件夹同级别的WEB-INF文件,如下:
文件名为:webpack.prod.conf.js ,添加内容如下:
至此,即可解决如上问题。