Skip to content

Instantly share code, notes, and snippets.

@jiparis
Last active March 29, 2019 08:48
Show Gist options
  • Save jiparis/a125626a1c632a3b6fd39983323de8f8 to your computer and use it in GitHub Desktop.
Save jiparis/a125626a1c632a3b6fd39983323de8f8 to your computer and use it in GitHub Desktop.
Build and include React app in spring boot application (Gradle)
task buildFrontend(type: Exec){
workingDir './frontend'
if (System.getProperty('os.name').toLowerCase(Locale.ROOT).contains('windows')) {
commandLine('cmd', '/c', 'npm install')
commandLine('cmd', '/c', 'npm run build')
}
else {
commandLine('sh', '-c', 'npm install')
commandLine('sh', '-c', 'npm run build')
}
}
// Generate bundle
processResources.dependsOn(buildFrontend)
// Copy static resources from frontend in the processResource task
processResources {
from ('frontend/build') {
into 'static'
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment