https://github.com/yanhaijing/grunt-cssformat
format indent of css file
https://github.com/yanhaijing/grunt-cssformat
Last synced: 4 months ago
JSON representation
format indent of css file
- Host: GitHub
- URL: https://github.com/yanhaijing/grunt-cssformat
- Owner: yanhaijing
- License: mit
- Created: 2014-05-28T02:24:10.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2016-02-20T20:49:07.000Z (over 9 years ago)
- Last Synced: 2025-01-31T11:02:14.054Z (4 months ago)
- Language: JavaScript
- Homepage: https://www.npmjs.org/package/grunt-cssformat
- Size: 173 KB
- Stars: 4
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE-MIT
Awesome Lists containing this project
README
# grunt-cssformat [](https://travis-ci.org/yanhaijing/grunt-cssformat) [](http://gruntjs.com/) [](https://github.com/yanhaijing/grunt-cssformat/blob/master/LICENSE-MIT)
> format indent css file
## Getting Started
This plugin requires Grunt `~0.4.5`If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
```shell
npm install grunt-cssformat --save-dev
```Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
```js
grunt.loadNpmTasks('grunt-cssformat');
```## The "cssformat" task
### Overview
In your project's Gruntfile, add a section named `cssformat` to the data object passed into `grunt.initConfig()`.```js
grunt.initConfig({
cssformat: {
options: {
// Task-specific options go here.
},
your_target: {
// Target-specific file lists and/or options go here.
},
},
});
```### Options
#### options.indent
Type: `String`
Default value: `' '`(two space)A string value that is used to indent.
#### options.encode
Type: `String`
Default value: `'utf8'`A string value that is used to point out the encode of file.
### Usage Examples
#### Default Options
In this example, the default options are used to do something with whatever. So if the encode of `testing.css` file and the `123.css` file is default think `'utf8'`, default indent two space will be used.```js
grunt.initConfig({
cssformat: {
css: {
files: [{dest:'tmp/testing.css', src: ['test/fixtures/testing.css']}]
}
}
});
```
**demo***src*
```css
/* *** */
p{color:#fff;}
p a{color:#fff;}
p a img{color:#fff;}
```*after format*
indent is two space```css
/* *** */
p{color:#fff;}
p a{color:#fff;}
p a img{color:#fff;}
```#### Custom Options
In this example, custom options are used to do something else with whatever else. So if the encode of `testing` file `123` file is gbk or other, if you want to use tab width indent.```js
grunt.initConfig({
cssformat: {
options: {
indent: '\t',
encode: 'gbk',
},
files: [{dest:'tmp/testing.css', src: ['test/fixtures/testing.css']}]
},
});
```## Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).## Release History
_(Nothing yet)_