vue create frontend
└─bookshelf
├─build
├─gradle
└─src
├─frontend
├─main
└─test
src/frontend/vue.config.js
module.exports = {
devServer: {
port: 3000,
proxy: {
'/api': {
target: 'http://localhost:8080',
ws: true,
changeOrigin: true
}
}
},
}
/api
로 시작하는 요청이 http://localhost:8080
로 가도록 설정/main/resources/static
으로 옮기고src/frontend/vue.config.js
module.exports = {
//추가
outputDir: '../main/resources/static',
devServer: {
port: 3000,
proxy: {
'/api': {
target: 'http://localhost:8080',
ws: true,
changeOrigin: true
}
}
}
}
build.gradle
plugins {
id 'org.springframework.boot' version '2.5.2'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id "com.github.node-gradle.node" version "3.1.0" // <--- 추가
id 'java' //11
}
node {
version = '14.16.1'
npmVersion = '7.18.1'
download = true
workDir = file("${project.buildDir}/nodejs")
npmWorkDir = file("${project.buildDir}/npm")
}
plugins
에서 실행 환경 참고..//이미 빌드된 파일 삭제
task deleteVueArtifact(type: Delete) {
delete "src/main/resources/static"
}
//npm install
task frontNpmInstall(type: NpmTask) {
workingDir = file("${project.projectDir}/src/frontend")
args = ['install']
}
//npm run build
task npmBuild(type: NpmTask, dependsOn: ['deleteVueArtifact', 'frontNpmInstall']) {
workingDir = file("${project.projectDir}/src/frontend")
args = ['run', 'build']
}
processResources.dependsOn 'npmBuild'
task
추가와 gradle build
명령어 수행시 해당 task
수행하게 설정