The HTML compiler is a maven plugin. Its purpose is to provide compile time features for generating static HTML resources for a frontend project.
The idea is to make it easier to write webapps by allowing the developer to write source code and have the build system generate resources for deployment. No more minified files everywhere. No more manually compressing resources.
- To compile typescript the code calls
tsc
, have it in the PATH. - To compile js++ the code calls
js++
, have it in the PATH.
- Parses HTML as Pebble templates using the Pebble template engine
- Compresses HTML (remove comments, remove whitespace)
- Inlines javascript
- Minifies javascript
- Inlines images
- Inlines stylesheets
- Minifies stylesheets (removing comments, removing whitespace)
- Generates integrity tag for remote resources
- Adds an include statement to JavaScript
- Also compresses HTML inside script tag with type text/x-jquery-tmpl or text/html
- Allow for calling htmlcompiler features through the command line
- Inlining of link tags (favico)
- SCSS and LESS compiling
- Inline link tag to stylesheet into style tag
- Scaling images to a given size
- Remove unnecessary meta tag in output
- Inline remotely hosted JavaScript and CSS
- Check validity using integrity tag
- Add support for Autoprefixer, or autoprefixer4j
- Add this code to the pom:
<plugin>
<groupId>com.github.codemonstur</groupId>
<artifactId>htmlcompiler</artifactId>
<version>5.7.6</version>
<executions>
<execution><goals><goal>compile</goal></goals></execution>
</executions>
</plugin>
- Run
mvn package
The code will compile all HTML files in src/main/websrc
to target/classes/webbin
while mirroring the directory structure.
For an example how to set this up see here: in the example
subdirectory.