diff --git a/deployment/src/main/java/io/quarkiverse/web/bundler/deployment/WebBundlerProcessor.java b/deployment/src/main/java/io/quarkiverse/web/bundler/deployment/WebBundlerProcessor.java index d26b227..eed78f4 100644 --- a/deployment/src/main/java/io/quarkiverse/web/bundler/deployment/WebBundlerProcessor.java +++ b/deployment/src/main/java/io/quarkiverse/web/bundler/deployment/WebBundlerProcessor.java @@ -15,6 +15,7 @@ import java.nio.file.Path; import java.nio.file.StandardCopyOption; import java.nio.file.StandardOpenOption; +import java.time.Instant; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -124,14 +125,13 @@ void bundle(WebBundlerConfig config, && Files.isDirectory(bundlesBuildContext.bundleDistDir())) { LOGGER.debug("Bundling not needed for live reload"); handleBundleDistDir(config, generatedBundleProducer, staticResourceProducer, bundlesBuildContext.bundleDistDir(), - false); + null, false); return; } boolean hasScssChange = isLiveReload && liveReload.getChangedResources().stream().anyMatch(WebBundlerProcessor::isSassFile); final Bundler.BundleType type = Bundler.BundleType.valueOf(webDependencies.getType().toString()); final Path targetDir = outputTarget.getOutputDirectory().resolve(TARGET_DIR_NAME); - try { if (!isLiveReload) { FileUtil.deleteDirectory(targetDir); @@ -201,6 +201,24 @@ void bundle(WebBundlerConfig config, } } if (addedEntryPoints > 0) { + + if (!isLiveReload + || !Objects.equals(webDependencies.getDependencies(), bundlesBuildContext.webDependencies())) { + long startedInstall = Instant.now().toEpochMilli(); + Bundler.install(targetDir, webDependencies.getDependencies(), type); + final long duration = Instant.now().minusMillis(startedInstall).toEpochMilli(); + if (LOGGER.isDebugEnabled()) { + String deps = webDependencies.getDependencies().stream().map(Path::getFileName).map(Path::toString) + .collect( + Collectors.joining(", ")); + LOGGER.infof("%d %s Web dependencies installed in %sms: %s", webDependencies.getDependencies().size(), + webDependencies.getType(), duration, deps); + } else { + LOGGER.infof("%d %s Web Dependencies installed in %sms ", webDependencies.getDependencies().size(), + webDependencies.getType(), duration); + } + } + final long startedBundling = Instant.now().toEpochMilli(); // SCSS conversion if (!isLiveReload || hasScssChange) { try (Stream stream = Files.find(targetDir, Integer.MAX_VALUE, @@ -209,26 +227,13 @@ && isCompiledSassFile(p.getFileName().toString()))) { stream.forEach(p -> convertToScss(p, targetDir)); } } - if (isLiveReload - && !Objects.equals(webDependencies.getDependencies(), bundlesBuildContext.webDependencies())) { - Bundler.install(targetDir, webDependencies.getDependencies(), type); - String deps = webDependencies.getDependencies().stream().map(Path::getFileName).map(Path::toString).collect( - Collectors.joining(", ")); - LOGGER.infof("%s Web dependencies changed: %s", webDependencies.getType(), deps); - } else { - if (!isLiveReload) { - String deps = webDependencies.getDependencies().stream().map(Path::getFileName).map(Path::toString) - .collect( - Collectors.joining(", ")); - LOGGER.infof("%s Web dependencies detected: %s", webDependencies.getType(), deps); - } - } final BundleResult result = Bundler.bundle(options.build()); if (!result.result().output().isBlank()) { LOGGER.debugf(result.result().output()); } - handleBundleDistDir(config, generatedBundleProducer, staticResourceProducer, result.dist(), true); + handleBundleDistDir(config, generatedBundleProducer, staticResourceProducer, result.dist(), startedBundling, + true); liveReload.setContextObject(BundlesBuildContext.class, new BundlesBuildContext(webDependencies.getDependencies(), entryPoints, result.dist())); } else { @@ -276,7 +281,8 @@ static void convertToScss(Path file, Path root) { } void handleBundleDistDir(WebBundlerConfig config, BuildProducer generatedBundleProducer, - BuildProducer staticResourceProducer, Path bundleDir, boolean changed) { + BuildProducer staticResourceProducer, Path bundleDir, Long started, + boolean changed) { try { Map bundle = new HashMap<>(); final String bundlePublicPath = surroundWithSlashes(config.bundleDir()); @@ -297,13 +303,19 @@ void handleBundleDistDir(WebBundlerConfig config, BuildProducer