npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

gulp-light-css

v1.3.0

Published

在编译时屏蔽 css import,避免冗余

Readme

gulp-light-css

在编译时注释掉 css import,避免拷贝产生冗余。

css 编译器一般会将依赖拷贝进使用依赖的文件,如果有多个文件使用同一个依赖,那么这个依赖会被拷贝多次。

在编译器读取文件之前,先把原本的依赖替换掉,让编译器不拷贝该依赖。编译结束后还原依赖,使用 @import 来引入编译好的依赖。

usage

npm i -D gulp-light-css

gulpfile.js:

const less = require('gulp-less');
const lightcss = require('gulp-light-css');

function cssTask() {
  return gulp.src(['src/**/*.less'])
    .pipe(lightcss({
      compiler: less(),
      ignores: ['**/_{vars,mixin}.less'],
    }))
    .pipe(gulp.dest('dist'));
}

options

ignores

type | default |required --|--|-- glob[]|['**/*']| false 用于插件忽略处理某些依赖,默认全部忽略,相当于未使用该插件。

一般忽略 vars、mixin 等文件。如果不忽略,将会产生找不到变量或mixin的错误。

e.g.

@import './var.less';
@import './base.less';
div {
  color: @black;
}

默认情况下,使用 ignores: ['**/*'] ,输出给编译器的文件如下:

/* 依赖不会被替换,编译器不会处理忽略的依赖 */
@import './var.less';
@import './base.less';
div {
  color: @black; /* error:找不到变量 */
}

设置 ignores: ['**/var.less'] 后,输出给编译器的文件:

@import './var.less'; /* 插件不会处理该依赖 */
css-light0{display:block} /* 对应 @import './base.less'; */
div {
  color: @black;
}

设置 ignores: [] 后,输出给编译器的文件:

/* 依赖被替换,编译器不会处理该依赖 */
css-light0{display:block} /* 对应 @import './var.less'; */
css-light1{display:block} /* 对应 @import './base.less'; */
div {
  color: @black; /* error:找不到变量 */
}

compiler

type | default |required --|--|-- Stream|null| true

样式文件使用的编译器。

ignoreNodeModules

type | default |required --|--|-- boolean|true| false

是否忽略 node_modules 模块,默认忽略,让编译器去拷贝打包。

notPackIgnoreFiles

type | default |required --|--|-- boolean|false| false

是否不打包 ignores 忽略的模块,使其仅用于编译时。默认打包。

ext

type | default |required --|--|-- string|.css| false

替换引入依赖语句的扩展名。

e.g.

@import './base.less';
=>
@import './base.css';