Skip to content

Instantly share code, notes, and snippets.

@jsrois
Created March 2, 2022 13:56
Show Gist options
  • Save jsrois/7b12a6eaf48f609ad638f3d401acb02d to your computer and use it in GitHub Desktop.
Save jsrois/7b12a6eaf48f609ad638f3d401acb02d to your computer and use it in GitHub Desktop.
How to compile and copy the frontend build to the resources folder in a spring boot project
// include in `build.gradle`
// using `apply from: 'frontend.gradle'`
node {
nodeProjectDir = file("./frontend-app")
}
task buildFrontendApp(type: NpmTask) {
args = ['run', 'build']
}
task copyFrontendApp(type: Copy) {
dependsOn('buildFrontendApp')
from('./frontend-app/build')
into("./src/main/resources/static")
}
buildFrontendApp.dependsOn npmInstall
processResources.dependsOn copyFrontendApp
copyFrontendApp.dependsOn buildFrontendApp
build.dependsOn copyFrontendApp
@jsrois
Copy link
Author

jsrois commented Mar 2, 2022

Also add the node-gradle plugin to the build.gradle file using

plugins {
   // ...
  id 'com.github.node-gradle.node' version '3.2.1'
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment