@frappe/esbuild-plugin-postcss2

中文文档
0.1.3发布于 2022/03/15MITTypeScriptESM + CJS近 30 天下载 90.1万

使用有建置的邮箱

中文使用文档
文档目录5 节
  1. 安装
  2. 使用量
  3. PostCSS 插件
  4. CSS 模块
  5. 预处理器

找维护者!

不幸的是,我没有时间 做这个插件。 请联系我 如果你想接手这个项目的话.

安装-插管-后置2

此插件是一个优化的, 类型友好的版本 安装-插图-站点它支持CSS预处理器和CSS模块.

安装

yarn add -D esbuild-plugin-postcss2

或者说

npm i -D esbuild-plugin-postcss2

使用量

将插件添加到您的新建插件中 :

const esbuild = require("esbuild");
const postCssPlugin = require("esbuild-plugin-postcss2");

esbuild.build({
  ...
  plugins: [
    postCssPlugin.default()
  ]
  ...
});

PostCSS 插件

将您想要的 PostCSS 插件添加到插件阵列 :

const autoprefixer = require("autoprefixer");

esbuild.build({
  ...
  plugins: [
    postCssPlugin.default({
      plugins: [autoprefixer]
    })
  ]
  ...
});

CSS 模块

PostCSS模块默认启用. 您可以在配置中通过, 也可以用 modules 字段 :

postCssPlugin.default({
  // pass in `postcss-modules` custom options
  // set to false to disable
  modules: {
    getJSON(cssFileName, json, outputFileName) {
      const path = require("path");
      const cssName = path.basename(cssFileName, ".css");
      const jsonFileName = path.resolve("./build/" + cssName + ".json");

      fs.writeFileSync(jsonFileName, JSON.stringify(json));
    }
  }
});

根据标准,任何文件 module 扩展前( ie) somefile.module.css)将作为模块处理. 选项 fileIsModule 允许推翻此行为.

postCssPlugin.default({
  // pass a custom `fileIsModule` option to tell whether a file should be treated as a module
  // in this example we want everything to be a module except file finishing with `global.css`
  fileIsModule: (filepath) => !filepath.endsWith(".global.css")
});

预处理器

用于使用预处理器( E)sass, (中文(简体) ), scss, (中文(简体) ), stylus, (中文(简体) ), less),只要添加想要的预处理器作为 devDependency数字 :

yarn add -D sass

版本与发布记录

@frappe/esbuild-plugin-postcss2 共发布 2 个版本,首次发布于 2022/03/14;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.1.3latest2022/03/154 年前
0.1.22022/03/144 年前

关于 @frappe/esbuild-plugin-postcss2 的常见问题

@frappe/esbuild-plugin-postcss2 是什么?

使用有建置的邮箱

如何安装 @frappe/esbuild-plugin-postcss2?

在项目目录运行 npm install @frappe/esbuild-plugin-postcss2,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:less(^4.x)、sass(^1.x)、stylus(^0.x)、postcss(8.x)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@frappe/esbuild-plugin-postcss2 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@frappe/esbuild-plugin-postcss2 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@frappe/esbuild-plugin-postcss2 可以商用吗?

@frappe/esbuild-plugin-postcss2 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@frappe/esbuild-plugin-postcss2 的下载量有多少?

根据 npm 官方下载统计,@frappe/esbuild-plugin-postcss2 在 2026/10/16 – 2026/11/14 这 30 天内被下载 901,219 次,日均约 30,041 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@frappe/esbuild-plugin-postcss2 还在维护吗?

最新版本 0.1.3 发布于 2022/03/15(4 年前);至今共发布 2 个版本,其中过去 12 个月发布了 0 个;首次发布于 2022/03/14。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。