Fork me on GitHub

Output file structure (imports' tree)

You can decide how the output file structure will look after split by two parameters:

  1. maxRules - maximum number of CSS rules in a single "part"
  2. maxImports - maximum number of generated @import in a single file

List of examples:

For the purposes of the examples the following source file (style.css) will be used:

rule {
    attr1: value1;
    attr2: value2;
    attr3: value3;
    attr4: value4;
    attr5: value5;
}

All diagrams have been created in UMLet (Free UML Tool for Fast UML Diagrams) application.

Whole code in single file

If your code contains fewer rules than the value of the maxRules parameter, it is placed in a single file.

<project>
   ...
   <build>
      <plugins>
         ...
         <plugin>
            <groupId>biz.gabrys.maven.plugins</groupId>
            <artifactId>css-splitter-maven-plugin</artifactId>
            <version>2.0.0</version>
            <executions>
               <execution>
                  <goals>
                     <goal>split</goal>
                  </goals>
                  <configuration>
                     <maxRules>10</maxRules>
                     <maxImports>10</maxImports>
                  </configuration>
               </execution>
            </executions>
         </plugin>
      </plugins>
   </build>
<project>

The output file structure:
file structure

Flat imports' tree

If your code code contains fewer rules than the value of the maxRules parameter and the maxImports parameter value is big enough too store all @import operations in a single file, the plugin creates a single file which imports all "parts".

<project>
   ...
   <build>
      <plugins>
         ...
         <plugin>
            <groupId>biz.gabrys.maven.plugins</groupId>
            <artifactId>css-splitter-maven-plugin</artifactId>
            <version>2.0.0</version>
            <executions>
               <execution>
                  <goals>
                     <goal>split</goal>
                  </goals>
                  <configuration>
                     <maxRules>1</maxRules>
                     <maxImports>10</maxImports>
                  </configuration>
               </execution>
            </executions>
         </plugin>
      </plugins>
   </build>
<project>

The output file structure:
file structure

Deep imports' tree

If your code code contains fewer rules than the value of the maxRules parameter and the maxImports parameter value is not big enough too store all @import operations in a single file, the plugin creates a single file which imports files, which imports files... and finally which imports "parts".

<project>
   ...
   <build>
      <plugins>
         ...
         <plugin>
            <groupId>biz.gabrys.maven.plugins</groupId>
            <artifactId>css-splitter-maven-plugin</artifactId>
            <version>2.0.0</version>
            <executions>
               <execution>
                  <goals>
                     <goal>split</goal>
                  </goals>
                  <configuration>
                     <maxRules>1</maxRules>
                     <maxImports>2</maxImports>
                  </configuration>
               </execution>
            </executions>
         </plugin>
      </plugins>
   </build>
<project>

The output file structure:
file structure