Quarkus logo Web Bundler - Getting Started

Create full-stack web apps and components with this Quarkus extension. It offers zero-configuration bundling and minification (with source-map) for your web app scripts (JS, JSX, TS, TSX), dependencies (jQuery, htmx, Bootstrap, Lit etc.), and styles (CSS, SCSS, SASS).

No need to install NodeJs, it relies on a Java wrapped version of esbuild. For libraries, all the NPM catalog is accessible through Maven or Gradle dependencies.

  • Easy to set up

  • Production build

  • Awesome Dev experience with browser live-reload

  • Integrated with NPM dependencies through mvnpm or WebJars.

  • Build-time index.html rendering with bundled scripts and styles

  • Server Side Qute Components (Qute template + Script + Style)

The Web Bundler has been pre-configured to reduce the complexity of web bundling. You don’t need to know all the concepts of web bundling (entry-points, loaders, …​) to use this extension, it has been pre-configured with sensible defaults that you may change if needed.

Installation

If you want to use this extension, you need to add the io.quarkiverse.web-bundler:quarkus-web-bundler extension first to your build file.

For instance, with Maven, add the following dependency to your POM file:

<dependency>
    <groupId>io.quarkiverse.web-bundler</groupId>
    <artifactId>quarkus-web-bundler</artifactId>
    <version>1.8.0</version>
</dependency>

Plug the bundle in your index.html template (More info on this):

src/main/resources/web/index.html
<html>
<head>
  ...
  {#bundle /}
</head>
</html>

Will compile into something looking like this:

<html>
<head>
      ...
      <script type="text/javascript" src="/static/main-XKHKUJNQ.js"></script>
      <link rel="stylesheet" media="screen" href="/static/main-TLNDARM3.css">
</head>
</html>

You are all set, enjoy web live coding!

By default {#bundle /} inserts both script and style tags for main, this is configurable.

Adding Scripts, Styles and Web Dependencies

Add your web resources in src/main/resources/web:

Add Web Dependencies to the pom and import them (scripts and styles):

web/app/script.js
import $ from 'jquery';
import 'bootstrap/dist/css/bootstrap.css';

$('.hello').innerText('Hello');
If you don’t import a Web Dependency, it won’t be bundled (dead code elimination).