Fork me on GitHub

css-splitter:split

Full name:

biz.gabrys.maven.plugins:css-splitter-maven-plugin:2.0.3:split

Description:

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 "parts" 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 {
    }
}

Attributes:

  • Requires a Maven project to be executed.
  • Since version: 1.0.0.
  • Binds by default to the lifecycle phase: process-sources.

Optional Parameters

Name Type Since Description
<cacheTokenParameter> String 1.0.0 Defines a cache token parameter name which will be added to @import links in destination CSS stylesheets.
Notice: ignored when cache token type is equal to none.
Default value is: v.
User property is: css.splitter.cacheTokenParameter.
<cacheTokenType> String 1.0.0 Defines a cache token type which will be added to @import links in destination CSS stylesheets. Available options:
  • custom - text specified by the user
  • date - build date
  • none - token will not be added

Default value is: none.
User property is: css.splitter.cacheTokenType.
<cacheTokenValue> String 1.0.0 Stores different values depending on the cache token type:
  • custom - user specified value (e.g. constantText, ${variable})
  • date - pattern for SimpleDateFormat object
  • none - ignored
Default value is: yyyyMMddHHmmss if cache token type is equal to date.
Required: YES if cache token type is equal to custom.
User property is: css.splitter.cacheTokenValue.
<compress> boolean 1.1.0 Whether the plugin should use YUI Compressor to compress the CSS code.
Default value is: false.
User property is: css.splitter.compress.
<compressLineBreak> int 1.1.0 Defines a column number after which the plugin will insert a line break. From YUI Compressor documentation:
Some source control tools do not like files containing lines longer than, say 8000 characters. The line break option is used in that case to split long lines after a specific column. Specify 0 to get a line break after each rule in CSS.
Notice: all values smaller than 0 means - do not split the line after any column.
Default value is: -1.
User property is: css.splitter.compressLineBreak.
<encoding> String 1.0.0 Sources encoding.
Default value is: ${project.build.sourceEncoding}.
User property is: css.splitter.encoding.
<excludes> String[] 1.0.0 List of files to exclude. Specified as fileset patterns which are relative to the source directory. See available fileset patterns formats.
Default value is: [].
<filesetPatternFormat> String 1.0.0 Defines inclusion and exclusion fileset patterns format. Available options:
  • ant - Ant patterns
  • regex - regular expressions (use '/' as path separator)

Default value is: ant.
User property is: css.splitter.filesetPatternFormat.
<force> boolean 1.0.0 Forces to always split the CSS stylesheets. By default sources are only split when modified or the main destination file does not exist.
Default value is: false.
User property is: css.splitter.force.
<importsDepthLimit> int 1.0.0 The plugin fails a build when a number of @import depth levels exceed this value. The plugin ignores @import operations that come from the source code.
Notice: all values smaller than 1 are treated as 4.
Default value is: 4.
User property is: css.splitter.importsDepthLimit.
<includes> String[] 1.0.0 List of files to include. Specified as fileset patterns which are relative to the source directory. See available fileset patterns formats.
Default value is: ["**/*.css"] for ant or ["^.+\.css$"] for regex.
<maxImports> int 1.0.0 The maximum number of generated @import in a single file. The plugin ignores @import operations that come from the source code.
Notice: all values smaller than 2 are treated as 31.
Default value is: 31.
User property is: css.splitter.maxImports.
<maxRules> int 1.0.0 The maximum number of CSS rules in a single "part".
Notice: all values smaller than 1 are treated as 4095.
Default value is: 4095.
User property is: css.splitter.maxRules.
<nonstrict> boolean 1.0.0 Defines whether the plugin runs in non-strict mode. In non-strict mode a CSS parser adds support for non-standard structures (e.g. @page rule inside @media).
Notice: this functionality may stop working or be removed at any time. You should fix your code instead of relying on this functionality.
Default value is: false.
User property is: css.splitter.nonstrict.
<outputDirectory> File 1.0.0 Specifies where to place split CSS stylesheets.
Default value is: ${project.build.directory}.
User property is: css.splitter.outputDirectory.
<outputFileNamePattern> String 1.0.0 Destination files naming pattern. {fileName} is equal to source file name without extension.
Default value is: {fileName}.css.
User property is: css.splitter.outputFileNamePattern.
<outputPartNamePattern> String 1.0.0 Destination "parts" naming pattern. {fileName} is equal to source file name without extension, {index} is equal to "part" index (first is equal to 1). "Parts" are loaded in the browsers according to indexes. For correct listing files on all operating systems indexes can contain leading zeros.
Default value is: {fileName}-{index}.css.
User property is: css.splitter.outputPartNamePattern.
<rulesLimit> int 1.0.0 The plugin fails the build when a number of the CSS rules in a source file exceed this value.
Notice: all values smaller than 1 are treated as 2147483647.
Default value is: 2147483647.
User property is: css.splitter.rulesLimit.
<skip> boolean 1.0.0 Defines whether to skip the plugin execution.
Default value is: false.
User property is: css.splitter.skip.
<sourceDirectory> File 1.0.0 The directory which contains the CSS stylesheets.
Default value is: ${project.basedir}/src/main/css.
User property is: css.splitter.sourceDirectory.
<standard> String 1.0.0 The CSS standard used to parse source code. Available values:
Default value is: 3.0.
User property is: css.splitter.standard.
<starHackAllowed> boolean 1.2.0 Defines whether the plugin allows using "star hack" in stylesheets. "Star hack" works only in Internet Explorer browsers - versions 7 and older. Example:
color {
  color: red;   /* all browsers */
  *color: blue; /* IE7 and below */
}
Notice: ignored when standard is equal to 1.0 or 2.0.
Default value is: false.
User property is: css.splitter.starHackAllowed.
<verbose> boolean 1.0.0 Defines whether the plugin runs in verbose mode.
Notice: always true in debug mode.
Default value is: false.
User property is: css.splitter.verbose.

Parameter Details

<cacheTokenParameter>

Defines a cache token parameter name which will be added to @import links in destination CSS stylesheets.
Notice: ignored when cache token type is equal to none.
  • Type: java.lang.String
  • Since: 1.0.0
  • Required: No
  • User Property: css.splitter.cacheTokenParameter
  • Default: v

<cacheTokenType>

Defines a cache token type which will be added to @import links in destination CSS stylesheets. Available options:
  • custom - text specified by the user
  • date - build date
  • none - token will not be added
  • Type: java.lang.String
  • Since: 1.0.0
  • Required: No
  • User Property: css.splitter.cacheTokenType
  • Default: none

<cacheTokenValue>

Stores different values depending on the cache token type:
  • custom - user specified value (e.g. constantText, ${variable})
  • date - pattern for SimpleDateFormat object
  • none - ignored
Default value is: yyyyMMddHHmmss if cache token type is equal to date.
Required: YES if cache token type is equal to custom.
  • Type: java.lang.String
  • Since: 1.0.0
  • Required: No
  • User Property: css.splitter.cacheTokenValue

<compress>

Whether the plugin should use YUI Compressor to compress the CSS code.
  • Type: boolean
  • Since: 1.1.0
  • Required: No
  • User Property: css.splitter.compress
  • Default: false

<compressLineBreak>

Defines a column number after which the plugin will insert a line break. From YUI Compressor documentation:
Some source control tools do not like files containing lines longer than, say 8000 characters. The line break option is used in that case to split long lines after a specific column. Specify 0 to get a line break after each rule in CSS.
Notice: all values smaller than 0 means - do not split the line after any column.
  • Type: int
  • Since: 1.1.0
  • Required: No
  • User Property: css.splitter.compressLineBreak
  • Default: -1

<encoding>

Sources encoding.
  • Type: java.lang.String
  • Since: 1.0.0
  • Required: No
  • User Property: css.splitter.encoding
  • Default: ${project.build.sourceEncoding}

<excludes>

List of files to exclude. Specified as fileset patterns which are relative to the source directory. See available fileset patterns formats.
Default value is: [].
  • Type: java.lang.String[]
  • Since: 1.0.0
  • Required: No

<filesetPatternFormat>

Defines inclusion and exclusion fileset patterns format. Available options:
  • ant - Ant patterns
  • regex - regular expressions (use '/' as path separator)
  • Type: java.lang.String
  • Since: 1.0.0
  • Required: No
  • User Property: css.splitter.filesetPatternFormat
  • Default: ant

<force>

Forces to always split the CSS stylesheets. By default sources are only split when modified or the main destination file does not exist.
  • Type: boolean
  • Since: 1.0.0
  • Required: No
  • User Property: css.splitter.force
  • Default: false

<importsDepthLimit>

The plugin fails a build when a number of @import depth levels exceed this value. The plugin ignores @import operations that come from the source code.
Notice: all values smaller than 1 are treated as 4.
  • Type: int
  • Since: 1.0.0
  • Required: No
  • User Property: css.splitter.importsDepthLimit
  • Default: 4

<includes>

List of files to include. Specified as fileset patterns which are relative to the source directory. See available fileset patterns formats.
Default value is: ["**/*.css"] for ant or ["^.+\.css$"] for regex.
  • Type: java.lang.String[]
  • Since: 1.0.0
  • Required: No

<maxImports>

The maximum number of generated @import in a single file. The plugin ignores @import operations that come from the source code.
Notice: all values smaller than 2 are treated as 31.
  • Type: int
  • Since: 1.0.0
  • Required: No
  • User Property: css.splitter.maxImports
  • Default: 31

<maxRules>

The maximum number of CSS rules in a single "part".
Notice: all values smaller than 1 are treated as 4095.
  • Type: int
  • Since: 1.0.0
  • Required: No
  • User Property: css.splitter.maxRules
  • Default: 4095

<nonstrict>

Defines whether the plugin runs in non-strict mode. In non-strict mode a CSS parser adds support for non-standard structures (e.g. @page rule inside @media).
Notice: this functionality may stop working or be removed at any time. You should fix your code instead of relying on this functionality.
  • Type: boolean
  • Since: 1.0.0
  • Required: No
  • User Property: css.splitter.nonstrict
  • Default: false

<outputDirectory>

Specifies where to place split CSS stylesheets.
  • Type: java.io.File
  • Since: 1.0.0
  • Required: No
  • User Property: css.splitter.outputDirectory
  • Default: ${project.build.directory}

<outputFileNamePattern>

Destination files naming pattern. {fileName} is equal to source file name without extension.
  • Type: java.lang.String
  • Since: 1.0.0
  • Required: No
  • User Property: css.splitter.outputFileNamePattern
  • Default: {fileName}.css

<outputPartNamePattern>

Destination "parts" naming pattern. {fileName} is equal to source file name without extension, {index} is equal to "part" index (first is equal to 1). "Parts" are loaded in the browsers according to indexes. For correct listing files on all operating systems indexes can contain leading zeros.
  • Type: java.lang.String
  • Since: 1.0.0
  • Required: No
  • User Property: css.splitter.outputPartNamePattern
  • Default: {fileName}-{index}.css

<rulesLimit>

The plugin fails the build when a number of the CSS rules in a source file exceed this value.
Notice: all values smaller than 1 are treated as 2147483647.
  • Type: int
  • Since: 1.0.0
  • Required: No
  • User Property: css.splitter.rulesLimit
  • Default: 2147483647

<skip>

Defines whether to skip the plugin execution.
  • Type: boolean
  • Since: 1.0.0
  • Required: No
  • User Property: css.splitter.skip
  • Default: false

<sourceDirectory>

The directory which contains the CSS stylesheets.
  • Type: java.io.File
  • Since: 1.0.0
  • Required: No
  • User Property: css.splitter.sourceDirectory
  • Default: ${project.basedir}/src/main/css

<standard>

  • Type: java.lang.String
  • Since: 1.0.0
  • Required: No
  • User Property: css.splitter.standard
  • Default: 3.0

<starHackAllowed>

Defines whether the plugin allows using "star hack" in stylesheets. "Star hack" works only in Internet Explorer browsers - versions 7 and older. Example:
color {
  color: red;   /* all browsers */
  *color: blue; /* IE7 and below */
}
Notice: ignored when standard is equal to 1.0 or 2.0.
  • Type: boolean
  • Since: 1.2.0
  • Required: No
  • User Property: css.splitter.starHackAllowed
  • Default: false

<verbose>

Defines whether the plugin runs in verbose mode.
Notice: always true in debug mode.
  • Type: boolean
  • Since: 1.0.0
  • Required: No
  • User Property: css.splitter.verbose
  • Default: false