Last active
March 29, 2019 08:48
-
-
Save jiparis/a125626a1c632a3b6fd39983323de8f8 to your computer and use it in GitHub Desktop.
Build and include React app in spring boot application (Gradle)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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