diff --git a/deployment/src/main/java/io/quarkiverse/web/bundler/deployment/WebBundlerConfig.java b/deployment/src/main/java/io/quarkiverse/web/bundler/deployment/WebBundlerConfig.java index 9edaa55..7d5348a 100644 --- a/deployment/src/main/java/io/quarkiverse/web/bundler/deployment/WebBundlerConfig.java +++ b/deployment/src/main/java/io/quarkiverse/web/bundler/deployment/WebBundlerConfig.java @@ -5,6 +5,7 @@ import static java.util.function.Predicate.not; import java.nio.charset.Charset; +import java.util.List; import java.util.Map; import java.util.Optional; import java.util.Set; @@ -66,6 +67,12 @@ default String fromWebRoot(String dir) { */ LoadersConfig loaders(); + /** + * This defines the list of external paths for esbuild (https://esbuild.github.io/api/#external). + * Instead of being bundled, the import will be preserved. + */ + Optional> externalImports(); + /** * Configure how dependencies are collected */ 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 fc5f8e0..52480fa 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 @@ -154,13 +154,19 @@ void bundle(WebBundlerConfig config, final Map loaders = computeLoaders(config); loaders.put(".scss", EsBuildConfig.Loader.CSS); + final EsBuildConfigBuilder esBuildConfigBuilder = new EsBuildConfigBuilder() + .loader(loaders) + .addExternal(surroundWithSlashes(config.staticDir()) + "*") + .minify(launchMode.getLaunchMode().equals(LaunchMode.NORMAL)); + if (config.externalImports().isPresent()) { + for (String e : config.externalImports().get()) { + esBuildConfigBuilder.addExternal(e); + } + } final BundleOptionsBuilder options = new BundleOptionsBuilder() .setWorkFolder(targetDir) .withDependencies(webDependencies.getDependencies()) - .withEsConfig(new EsBuildConfigBuilder() - .loader(loaders) - .addExternal(surroundWithSlashes(config.staticDir()) + "*") - .minify(launchMode.getLaunchMode().equals(LaunchMode.NORMAL)).build()) + .withEsConfig(esBuildConfigBuilder.build()) .withType(type); int addedEntryPoints = 0; for (EntryPointBuildItem entryPoint : entryPoints) { diff --git a/docs/modules/ROOT/pages/includes/quarkus-web-bundler.adoc b/docs/modules/ROOT/pages/includes/quarkus-web-bundler.adoc index bfbd57f..0757f06 100644 --- a/docs/modules/ROOT/pages/includes/quarkus-web-bundler.adoc +++ b/docs/modules/ROOT/pages/includes/quarkus-web-bundler.adoc @@ -362,6 +362,22 @@ endif::add-copy-button-to-env-var[] |`json` +a|icon:lock[title=Fixed at build time] [[quarkus-web-bundler_quarkus.web-bundler.external-imports]]`link:#quarkus-web-bundler_quarkus.web-bundler.external-imports[quarkus.web-bundler.external-imports]` + +[.description] +-- +This defines the list of external paths for esbuild (https://esbuild.github.io/api/++#++external). Instead of being bundled, the import will be preserved. + +ifdef::add-copy-button-to-env-var[] +Environment variable: env_var_with_copy_button:+++QUARKUS_WEB_BUNDLER_EXTERNAL_IMPORTS+++[] +endif::add-copy-button-to-env-var[] +ifndef::add-copy-button-to-env-var[] +Environment variable: `+++QUARKUS_WEB_BUNDLER_EXTERNAL_IMPORTS+++` +endif::add-copy-button-to-env-var[] +--|list of string +| + + a|icon:lock[title=Fixed at build time] [[quarkus-web-bundler_quarkus.web-bundler.dependencies.type]]`link:#quarkus-web-bundler_quarkus.web-bundler.dependencies.type[quarkus.web-bundler.dependencies.type]` [.description]