百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
D

doiuse

> 编程语言
开源

:bomb: 使用 Lint CSS 来检查浏览器是否支持 caniuse 数据库。

1.3K stars0 点赞2 次浏览
访问官网GitHub

工具介绍

:bomb: 使用 Lint CSS 来检查浏览器是否支持 caniuse 数据库。

doiuse

Lint CSS 可用于浏览器支持 Can I use 数据库。

安装

bash
npm install -g doiuse

使用示例

命令行

bash
doiuse --browsers "ie >= 9, > 1%, last 2 versions" main.css
# or
cat main.css | doiuse --browsers "ie >= 9, > 1%, last 2 versions"

示例输出:

…

使用 --json 可将输出结果以 (换行分隔) JSON 对象的形式输出。

JS

javascript
import postcss from 'postcss';
import DoIUse from 'doiuse/lib/DoIUse.js';

postcss(new DoIUse({
  browsers:['ie >= 6', '> 1%'],
  ignore: ['rem'], // an optional array of features to ignore
  ignoreFiles: ['**/normalize.css'], // an optional array of file globs to match against original source file path, to ignore
  onFeatureUsage: (usageInfo) => {
    console.log(usageInfo.message);
  }
})).process("a { background-size: cover; }")

如果使用 var doiuse = require('doiuse'), 仍然支持 CommonJS 语法。

Gulp (CommonJS)

javascript
var gulp = require('gulp')
var postcss = require('postcss')
var doiuse = require('doiuse')

gulp.src(src, { cwd: process.cwd() })
.pipe(gulp.postcss([
  doiuse({
    browsers: [
      'ie >= 8',
      '> 1%'
    ],
    ignore: ['rem'], // an optional array of features to ignore
    ignoreFiles: ['**/normalize.css'], // an optional array of file globs to match against original source file path, to ignore
    onFeatureUsage: function (usageInfo) {
      console.log(usageInfo.message)
    }
  })
]))

它是如何工作的

特别是,检测特征使用的方法目前还相当天真。 请参阅 /data/features.js 中的数据。

  • 如果该数据集中的某个特征仅指定了properties,那么我们只使用这些属性来匹配输入 CSS 中使用的属性。

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

JavaScript

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言