My current recipe which works not bad is
- setup spring at localhost:8082, vue-cli app on localhost:8080
- setup proxy in devServer for webpack to point all /api calls to localhost:8082. So now any calls made from vue application to /api will be sent to the spring application at /api
- setup spring api endpoints at /api
- add a 'buildx' npm task to do the usual "vue-cli build && copy " over to spring src/main/resources/static area, mine usually looks like this in package.json
"buildx": "vue-cli-service build && copyfiles -u 1 dist/* dist/**/* ../build/resources/main/public && copyfiles -u 1 dist/* dist/**/* ../src/main/resources/public -V",
- I usually copy to both build/ and src area, since build makes restart instantliy work in spring side, and src/ area makes bundle available in spring jar file created using bootJar task, for deployment
- setup devtools on spring to autorestart
- I can dev/test using just localhost:8080 vue-cli based system alone
- final testing using spring application at localhost:8082
for production, just copy the spring jar file containing all resources, and no CORS or anything is needed since static bundle is part of application.
This works fine, the only piece I want to be able to improve on is #3 if possible since I have to run that copy task manually each time to load on spring (when I need to), but it works so not such a big deal.
This works fine, the only piece I want to be able to improve on is #3 if possible since I have to run that copy task manually each time to load on spring (when I need to), but it works so not such a big deal.
Comments
Post a Comment