Description of feature/enhancement
Add hot reloading for javascript.
Justification
This benefits developers so that they do not have to run npm run build for every javascript changes.
This has been sitting in a branch on my machine for the longest time, if it helps you. With this, running the dev server and deploying from gradle automatically run npm run build if the javascript files aren't up to date:
build.gradle | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/build.gradle b/build.gradle
index 5aecd6d..2709bed 100644
--- a/build.gradle
+++ b/build.gradle
@@ -12,6 +12,8 @@ apply plugin: "pmd"
apply plugin: "findbugs"
apply plugin: "jacoco"
+apply plugin: "com.moowork.node"
+
def appengineVersion = "1.9.+"
def jsoupVersion = "1.10.3"
def checkstyleVersion = "8.7"
@@ -22,9 +24,13 @@ def guavaVersion = "22.0"
buildscript {
repositories {
jcenter()
+ maven {
+ url "https://plugins.gradle.org/m2/"
+ }
}
dependencies {
classpath "com.google.cloud.tools:appengine-gradle-plugin:1.3.4"
+ classpath "com.moowork.gradle:gradle-node-plugin:1.2.0"
}
}
@@ -323,6 +329,22 @@ task setupIntellijStaticAnalysis {
finalizedBy syncIntelliJCheckStyleVersion
}
+// JavaScript building
+
+node {
+ download = true
+}
+
+task buildJs(type: NpmTask) {
+ inputs.dir(file("src/main/webapp/dev/js"))
+ outputs.dir(file("src/main/webapp/js"))
+ outputs.dir(file("src/main/webapp/test"))
+
+ args = ["run", "build"]
+}
+
+war.dependsOn buildJs
+
// RUN SERVER TASKS
compileJava.options.encoding = "UTF-8"
Ah, finally someone opens this can of worms: Gradle Node plugin. If we use that plugin, there are more items in the lint/build chain that can be further streamlined.
Also, does this work for Eclipse/IntelliJ? I presume that some preparatory config needs to be set up in order for it to work, but I could be wrong.
Let me take a look at that.
Initially I was thinking of adding a hot reloading plugin within webpack, but if Gradle has it and it integrates well with the IDEs and existing Java code, then that should be a better solution.
I don't think the performance is good enough for use with IDEs though?
It appears that Gradle's performance is still not quite there yet, even with daemons.
I think what @Crphang was thinking about was hot reload during development, not hot reload after pulling changes, which are two different items really. Either way, it will be beneficial to have one (or both).
Resolved in V7.
Most helpful comment
I think what @Crphang was thinking about was hot reload during development, not hot reload after pulling changes, which are two different items really. Either way, it will be beneficial to have one (or both).