Fork me on GitHub

Plugin Documentation

Goals available for this plugin:

Goal Description
css-splitter:split

Splits CSS stylesheets to smaller files ("parts") which contain maximum X rules. The plugin performs the following steps:

  1. reads source code
  2. parses it using the CSS Parser (parser removes all comments)
  3. splits parsed document to "parts"
  4. builds imports' tree
  5. writes to files

During split process the plugin can divide "standard style" and @media rules, which size is bigger than 1, into smaller.

Example:

/* size is equal to 1, not splittable (size smaller than 2) */
@import 'file.css';

/* size is equal to 2, not splittable (not "standard style" or @media rule) */
@font-face {
     font-family: FontFamilyName;
     src: url("font.woff2") format("woff2"), url("font.ttf") format("truetype");
}

/* size is equal to 4, splittable */
.element {
     width: 100px;
     height: 200px;
     margin: 0;
     padding: 0;
}

/* size is equal to 1, not splittable (size smaller than 2) */
selector1, selector2 > selector3 {
     width: 200px;
}

/* size is equal to 1 (for safety), not splittable (size smaller than 2) */
.empty {
}

/* size is equal to 1, not splittable (size smaller than 2) */
@media screen and (min-width: 480px) {
}

/* size is equal to 4 (1 + 2 + 1), splittable */
@media screen and (min-width: 480px) {

    /* size is equal to 1, not splittable (size smaller than 2) */
    rule {
         width: 100px;
    }

    /* size is equal to 2, splittable */
    rule2 {
         width: 100px;
         height: 100px;
    }

    /* size is equal to 1 (for safety), not splittable (size smaller than 2) */
    .empty {
    }
}

System Requirements

The following specifies the minimum requirements to run this Maven plugin:

Maven 2.0.11
JDK 1.5
Memory No minimum requirement.
Disk Space No minimum requirement.

Usage

You should specify the version in your project's plugin configuration:

<project>
  ...
  <build>
    <!-- To define the plugin version in your parent POM -->
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>biz.gabrys.maven.plugins</groupId>
          <artifactId>css-splitter-maven-plugin</artifactId>
          <version>1.2.0</version>
        </plugin>
        ...
      </plugins>
    </pluginManagement>
    <!-- To use the plugin goals in your POM or parent POM -->
    <plugins>
      <plugin>
        <groupId>biz.gabrys.maven.plugins</groupId>
        <artifactId>css-splitter-maven-plugin</artifactId>
        <version>1.2.0</version>
      </plugin>
      ...
    </plugins>
  </build>
  ...
</project>

For more information, see "Guide to Configuring Plug-ins"