From 376f47570b378b4f9519462c55de90a708796798 Mon Sep 17 00:00:00 2001 From: Andy Damevin Date: Fri, 12 Jul 2024 17:02:00 +0200 Subject: [PATCH] Add LAUNCH_MODE env --- .../web/bundler/deployment/PrepareForBundlingProcessor.java | 5 +++-- .../quarkiverse/web/bundler/test/WebBundlerDevModeTest.java | 2 +- .../java/io/quarkiverse/web/bundler/test/WebBundlerTest.java | 3 ++- deployment/src/test/resources/web/app/app.js | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/deployment/src/main/java/io/quarkiverse/web/bundler/deployment/PrepareForBundlingProcessor.java b/deployment/src/main/java/io/quarkiverse/web/bundler/deployment/PrepareForBundlingProcessor.java index 0e3503c..f37910a 100644 --- a/deployment/src/main/java/io/quarkiverse/web/bundler/deployment/PrepareForBundlingProcessor.java +++ b/deployment/src/main/java/io/quarkiverse/web/bundler/deployment/PrepareForBundlingProcessor.java @@ -60,6 +60,7 @@ public class PrepareForBundlingProcessor { entry(EsBuildConfig.Loader.BINARY, LoadersConfig::binary)); public static final String TARGET_DIR_NAME = "web-bundler/"; public static final String DIST = "dist"; + private static final String LAUNCH_MODE_ENV = "LAUNCH_MODE"; static { for (EsBuildConfig.Loader loader : EsBuildConfig.Loader.values()) { @@ -152,8 +153,8 @@ ReadyForBundlingBuildItem prepareForBundling(WebBundlerConfig config, .outDir(PathUtils.join(DIST, config.bundlePath())) .publicPath(config.publicBundlePath()) .splitting(config.bundling().splitting()) - .sourceMap(config.bundling().sourceMapEnabled()); - + .sourceMap(config.bundling().sourceMapEnabled()) + .define(LAUNCH_MODE_ENV, "'" + launchMode.getLaunchMode().name() + "'"); if (browserLiveReload) { esBuildConfigBuilder .preserveSymlinks() diff --git a/deployment/src/test/java/io/quarkiverse/web/bundler/test/WebBundlerDevModeTest.java b/deployment/src/test/java/io/quarkiverse/web/bundler/test/WebBundlerDevModeTest.java index 5c390ba..5a3e0d1 100644 --- a/deployment/src/test/java/io/quarkiverse/web/bundler/test/WebBundlerDevModeTest.java +++ b/deployment/src/test/java/io/quarkiverse/web/bundler/test/WebBundlerDevModeTest.java @@ -45,7 +45,7 @@ public void test() throws InterruptedException { .body(Matchers.containsString("console.log(\"Hello World! Modified!\");")); test.modifyResourceFile("web/app/app.css", s -> s.replace("background-color: #6b6bf5;", "background-color: #123456;")); test.modifyResourceFile("web/app/other.scss", s -> s.replace("color: #AAAAAA;", "color: #567890;")); - Thread.sleep(500); + Thread.sleep(1000); RestAssured.given() .get("/foo/bar/static/bundle/main.css") .then() diff --git a/deployment/src/test/java/io/quarkiverse/web/bundler/test/WebBundlerTest.java b/deployment/src/test/java/io/quarkiverse/web/bundler/test/WebBundlerTest.java index 1c33c77..d8bda33 100644 --- a/deployment/src/test/java/io/quarkiverse/web/bundler/test/WebBundlerTest.java +++ b/deployment/src/test/java/io/quarkiverse/web/bundler/test/WebBundlerTest.java @@ -49,7 +49,8 @@ public void test() { .basePath("") .get(bundle.script("main")) .then() - .statusCode(200); + .statusCode(200) + .body(Matchers.containsString("hello world in test mode")); RestAssured.given() .get("/static/hello.txt") .then() diff --git a/deployment/src/test/resources/web/app/app.js b/deployment/src/test/resources/web/app/app.js index 5b08554..0d68218 100644 --- a/deployment/src/test/resources/web/app/app.js +++ b/deployment/src/test/resources/web/app/app.js @@ -1,5 +1,5 @@ import $ from 'jquery'; $(document).ready(function() { - console.log("hello " + HELLO_ENV); + console.log("hello " + HELLO_ENV + " in " + LAUNCH_MODE + " mode"); });