grunt-postcss-separator
This is a grunt wrapper for postcss-separator
.
Split up your Data-URI (or anything else) into a separate CSS file.
Written with PostCSS.
Installation
npm install grunt-postcss-separator
Usage
Read source.css
, process its content, and output processed CSS to styles.css
and data.css
.
If source.css
has:
You will get the following output:
Options
All options of postcss-separator
are available.
Furthermore you can use the option keepOrigin
:
keepOrigin (only available in Grunt)
Type: boolean
Default value: false
Keep the origin file untouched when defined as true
. When defined as false
the origin css file will be cleaned up.
Usage
You can enable this plugin in the Gruntfile.js
of your project like that:
grunt.loadNpmTasks('grunt-postcss-separator');
Example
Here are some grunt examples:
icons
task splits up your dataURIs (data
)prop
task splits up a specific property (background-image
)ie
task splits up all ie classes (.lt-ie9
)mediaQuery
task splits up all media queries which match the RegExpprint
task splits up all @media print
separator:options:keepOrigin: truedataFile: trueicons:options:pattern:matchValue: /data/ // The RegExp to match values withmatchParent: true // Rules (eg. in @media blocks) include their parent node.files:'tmp/icons.css': 'test/fixtures/source.css'prop:options:pattern:matchValue: false // The RegExp to match values withmatchProp: /background-image/ // The RegExp to match values withmatchParent: true // Rules (eg. in @media blocks) include their parent node.files:'tmp/prop.css': 'test/fixtures/source.css'ie:options:pattern:matchRule: /lt-ie9/ // The RegExp to match values withmatchMedia: false // The RegExp to match media queries withmatchParent: true // Rules (eg. in @media blocks) include their parent node.files:'tmp/ie.css': 'test/fixtures/source.css'mediaQuery:options:pattern:matchValue: false // The RegExp to match values withmatchRule: false // The RegExp to match values withmatchMedia: /?resolution\:\s*?\.??dppx/ // The RegExp to match media queries withmatchParent: false // Rules (eg. in @media blocks) include their parent node.files:'tmp/image.css': 'test/fixtures/source.css'print:options:pattern:matchValue: false // The RegExp to match values withmatchRule: false // The RegExp to match values withmatchMedia: false // The RegExp to match media queries withmatchParent: false // Rules (eg. in @media blocks) include their parent node.matchAtRuleType: /print/ // Rules (eg. in @media blocks) include their parent node.files:'tmp/print.css': 'source.css'
License
Copyright (c) 2015 Sebastian Fitzner. Licensed under the MIT license.
ToDos
- Add tests