PostCSS 可以删除文件中重复的css.
此插件不会改变原始的css文件,只是在打包的时候会删除重复的样式
这样写:
.foo {
width: 100px;
height: 100px;
}
.foo{
height: 100px;
width: 100px;
}
变成这样:
.foo {
width: 100px;
height: 100px;
}
$ npm install postcss-delete-duplicate-css
postcss([ require('postcss-delete-duplicate-css') ])
查看 PostCSS 文档 examples regarding usage.
- Type:
boolean
- Default:
false
是否删除空的样式
这样写:
.foo {
width: 100px;
}
div {}
变成这样:
.foo{
width: 100px
}
- Type:
boolean
- Default:
false
是否删除所有的注释
这样写:
/*This is the comment*/
div {
width: 100px;
height: 100px;
}
变成这样:
div {
width: 100px;
height: 100px
}
可以通过以下命令运行测试:
$ npm run test