Refactoring and removing unused CSS from SASS/LESS files

心不动则不痛 提交于 2019-11-29 03:03:20

问题


I am working on a big single page application [backbonejs and rails] which has LESS as the CSS preprocessor and the generated .css files has grown to such an extent that for IE we have to split it into 3 files with http://blesscss.com/

Though there are tools to detect unused css and linting css, I am unable to find a proper solution for refactoring LESS/SASS files directly from uncompiled files instead of a single large generated .css file.

Would like to know what is the best approach doing these tasks?

Thanks in advance !


回答1:


  1. For finding and remove unused CSS use Uncss which has implementation as tasks for Grunt and Gulp
  2. For finding unused variables in your SASS/LESS code- some script like this one.
  3. For debug source files instead one generated css- source maps
  4. To minify your code, use compressed output styles
  5. To automatically add vendor prefixes for browsers in your css use Autoprefixer
  6. Generally- provide Grunt or Gulp build for your css

P.S.: Some of the links are just for SASS- for Less there are similar solutions which are easy to find.




回答2:


I am using koala fro minify and combine SASS,LESS,CSS,JS

see koala and Docs



来源:https://stackoverflow.com/questions/20811204/refactoring-and-removing-unused-css-from-sass-less-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!