Skip to content

Maven plugin for creating bundle package of js and css files in Maven project.

License

Notifications You must be signed in to change notification settings

CH3CHO/bundler-maven-plugin

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bundler-maven-plugin

Build Status Maven Central

Maven plugin for creating bundle package of js and css files in Maven project.

This is a fork of https://github.com/kospiotr/bundler-maven-plugin.

Inspired by: https://github.com/dciccale/grunt-processhtml

Goals

  • process - analyse input html file for special comment block, create bundle resource packages and outputs html file with bundled blocks. Bundled resources are concatenated, minimized, optimized and if requested checksum is computed and used with bundled filename. (see example below)

Configuration properties

Property Description Sample Value
inputFilePah The path of a file to be optimized ${project.basedir}/src/main/resources/index.html
outputFilePath The output path of the optimized file ${project.build.outputDirectory}/index.html
hashingAlgorithm The algorithm used to generated hash of the file content to be used in the output file name
Possible values: MD5(default), SHA-1, SHA-256, SHA-384, SHA-512
MD5
verbose Whether to enable detailed output of the bundling process
Default: false
true
cssOptimizer The name of optimizer used to process CSS files.
Possible values: simple (default), yui, none
When choosing none, no optimization shall be performed. Contents from input files will just be concatenated and saved into the output file.
simple
jsOptimizer The name of optimizer used to process CSS files.
Possible values: simple (default), yui, none
When choosing none, no optimization shall be performed. Contents from input files will just be concatenated and saved into the output file.
simple
munge Should be true if the compressor should shorten local variable names when possible.
Only works if jsOptimize is set toyui.
Default: true
true
preserveAllSemiColons Should be true if the compressor should preserve all semicolons in the code.
Only works if jsOptimize is set toyui.
Default: true
true
disableOptimizations Should be true if the compressor should disable all micro optimizations.
Only works if jsOptimize is set toyui.
Default: true
true

Usage

Configure plugin:

      <plugin>
        <groupId>com.github.ch3cho</groupId>
        <artifactId>bundler-maven-plugin</artifactId>
        <version>1.12.2</version>
        <executions>
          <execution>
            <id>bundle</id>
            <goals>
              <goal>process</goal>
            </goals>
            <configuration>
              <inputFilePah>${project.basedir}/src/main/resources/index-dev.html</inputFilePah>
              <outputFilePath>${project.build.outputDirectory}/index.html</outputFilePath>
            </configuration>
          </execution>
        </executions>
      </plugin>

Create source file ${project.basedir}/src/main/resources/index-dev.html

<!DOCTYPE html>
<html lang="en">
<body>

<!-- bundle:js app-#hash#.min.js-->
<script src="js/lib.js"></script>
<script src="js/app.js"></script>
<!-- /bundle -->

<!-- bundle:css app-#hash#.min.css-->
<link href="css/lib.css"/>
<link href="css/app.css"/>
<!-- /bundle -->

</body>
</html>

After running plugin the result will be outputted to ${project.build.outputDirectory}/index.html

<!DOCTYPE html>
<html lang="en">
<body>

<script src="app-0874ac8910c7b3d2e73da106ebca7329.min.js"></script>
<link rel="stylesheet" href="app-4971211a240c63874c6ae8c82bd0c88c.min.css" />

</body>
</html>

Optimizers

Note

If you want to perform an in-place bundling and replace the original html file in the output directory, please set both inputFilePah and outputFilePath to the file in the output directory and change the plugin execution phase to process-resources.

About

Maven plugin for creating bundle package of js and css files in Maven project.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages

  • Java 95.0%
  • Groovy 2.8%
  • HTML 1.7%
  • Other 0.5%