Code Monkey home page Code Monkey logo

vue-clearcss-ext's Introduction

vue-clearcss

这是一个用来找出vue sfc类型文件中多余无用css代码的工具,完美解析scss和less,sass仅支持嵌套写法。 随着项目的不断迭代文件里会残留着大量多余且无用css,不像js和html,人为处理起来会非常麻烦且不可靠,所以就出现了这个库, 网上有几个评价不错的css处理工具如uncss等都不能直接在vue里面使用,所以我利用了vue的编译工具和postcss来完成这个功能

安装前请Install

npm install -g vue-clearcss

之后在vue文件中如果有无效的css则会出现如下警告 avatar

存在js中的class名和作用于子组件的class会被认为是无效的,可以用使用忽略注释 package.json 中使用

{
    "ignoreCss": [
        "page",
        {
        "reg": "page",
        "attr": "g"
        }
    ],
}

在css文件中 ignoreConfig(如例子中只要class链中包含了ff都会通过) 是作用于整个vue,ignorecss是作用于单个calss(注意事放在class里面,而且由于编译器的限制嵌套的class必须每个都写),建议使用ignoreConfig,

/* ignoreConfig ['ff'] */
.qw{
    color: #000;
}
.re{
    /* ignorecss */
    color: #000;
}

vue-clearcss-ext's People

Contributors

qiaokeli111 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.