Class PublicStyleSheetBundler

java.lang.Object
com.vaadin.base.devserver.PublicStyleSheetBundler

public final class PublicStyleSheetBundler extends Object
Utility that resolves and bundles public stylesheet resources referenced by @StyleSheet URLs, in development time.

It locates the CSS entry file under common source roots that map to the servlet context, and returns a single inlined CSS string with @import rules resolved, using CssBundler.

The following source roots are searched under the current project folder:

  • src/main/resources/META-INF/resources
  • src/main/resources/resources
  • src/main/resources/static
  • src/main/resources/public
  • src/main/webapp
For internal use only. May be renamed or removed in a future release.
  • Method Details

    • forResourceLocations

      public static PublicStyleSheetBundler forResourceLocations(List<File> roots)
      Creates a new bundler instance configured with an explicit list of source roots. Only existing directories are included.
      Parameters:
      roots - list of root directories to search in
      Returns:
      a configured PublicStyleSheetBundler
    • bundle

      public Optional<String> bundle(String url, String contextPath)
      Bundles the CSS content for the given stylesheet URL by resolving it against known public source roots and inlining any @import statements.
      Parameters:
      url - the stylesheet URL as used in @StyleSheet; may start with context:// or a leading '/'
      contextPath - the servlet context path
      Returns:
      the bundled CSS content if the entry file was found and bundled; otherwise, Optional.empty()
    • normalizeUrl

      public static String normalizeUrl(String url)
      Normalize an incoming stylesheet URL from @StyleSheet into a relative path under the servlet context.