Jelajahi Sumber

Added the ability to do live-editing of client-side code during development.

This bypasses the need to run maven on the client side, since a webjar won't need to be built while live-editing during development.
James Albright 7 tahun lalu
induk
melakukan
f5e87c31d8

+ 1 - 0
.gitignore

@@ -7,3 +7,4 @@
 pwm-parent.iml
 pwm-parent.iml
 pwmconfig/
 pwmconfig/
 ssprconfig/
 ssprconfig/
+/server/src/main/webapp/public/resources/webjars

+ 1 - 1
client/package.json

@@ -13,7 +13,7 @@
     "test": "karma start --NODE_ENV=test",
     "test": "karma start --NODE_ENV=test",
     "test-single-run": "karma start --NODE_ENV=test --singleRun --no-auto-watch",
     "test-single-run": "karma start --NODE_ENV=test --singleRun --no-auto-watch",
     "start": "webpack-dev-server --config=webpack.dev.js --NODE_ENV=dev --colors",
     "start": "webpack-dev-server --config=webpack.dev.js --NODE_ENV=dev --colors",
-    "sync": "webpack --config=webpack.build.js --NODE_ENV=production --output-path=../webapp/public/resources/app --watch --colors"
+    "sync": "webpack --config=webpack.build.js --NODE_ENV=production --output-path=../server/src/main/webapp/public/resources/webjars/pwm-client --watch --colors"
   },
   },
   "author": "",
   "author": "",
   "license": "ISC",
   "license": "ISC",

+ 6 - 0
server/src/main/java/password/pwm/http/servlet/resource/ResourceFileServlet.java

@@ -552,6 +552,12 @@ public class ResourceFileServlet extends HttpServlet implements PwmServlet {
             throws PwmUnrecoverableException
             throws PwmUnrecoverableException
     {
     {
         if (resourcePathUri.startsWith(WEBJAR_BASE_URL_PATH)) {
         if (resourcePathUri.startsWith(WEBJAR_BASE_URL_PATH)) {
+            // This allows us to override a webjar file, if needed.  Mostly helpful during development.
+            final File file = new File(servletContext.getRealPath(resourcePathUri));
+            if (file.exists()) {
+                return new RealFileResource(file);
+            }
+
             final String remainingPath = resourcePathUri.substring(WEBJAR_BASE_URL_PATH.length(), resourcePathUri.length());
             final String remainingPath = resourcePathUri.substring(WEBJAR_BASE_URL_PATH.length(), resourcePathUri.length());
 
 
             final String webJarName;
             final String webJarName;