@codestitchofficial/eleventy-plugin-minify

中文文档
1.1.3发布于 2024/12/18MITCommonJS近 30 天下载 2986

An Eleventy plugin to automatically minify files

原始使用文档
文档目录4 节
  1. Installation
  2. Usage
  3. Publish
  4. License

eleventy-plugin-files-minifier

[!NOTE]
This plugin is a continuation of eleventy-plugin-files-minifier by Benjamin Rancourt. This repo was seemingly abandoned and left projects with an unresolvable npm vulnerability. All we've done is forked the repo, updated the dependencies, and maintained this repo going forward. All credit goes where it is due!

This plugin allows you to automatically minify files when builting with Eleventy. It currently supports css, html, json, xml, xsl and webmanifest files.

Why should you minify your files? Simply to reduce the data transfered between your hosting servers and your visitors, even if some of them maybe some bots.

Under the hood, this plugin use the following plugins to minify code:

Installation

Install the dependency with NPM:

npm install @codestitchofficial/eleventy-plugin-minify --save-dev

Open up your Eleventy config file (probably .eleventy.js) and use addPlugin:

const eleventyPluginFilesMinifier = require("@codestitchofficial/eleventy-plugin-minify");
module.exports = (eleventyConfig) => {
  eleventyConfig.addPlugin(eleventyPluginFilesMinifier);
};

Usage

The plugin will automatically minify supported files, you don't need to do anything except the installation!

Make sure that the files you want to minify are currently written by Eleventy. If not, you can easily rename it and add Front matter options. For example, for the manifest.webmanifest file, I could rename it as manifest.webmanifest.njk and add the following code at his top:

---
eleventyExcludeFromCollections: true
permalink: /manifest.webmanifest
---

Publish

Increment the version defined in the package.json file and run the command below to publish the module in the registry:

# Dry run
npm publish --dry-run

# For real (are you really sure?)
npm publish --access public

License

The MIT License (MIT)

版本与发布记录

@codestitchofficial/eleventy-plugin-minify 共发布 2 个版本,首次发布于 2024/12/13;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.1.3latest2024/12/181.9 年前
1.1.22024/12/131.9 年前

关于 @codestitchofficial/eleventy-plugin-minify 的常见问题

@codestitchofficial/eleventy-plugin-minify 是什么?

An Eleventy plugin to automatically minify files

如何安装 @codestitchofficial/eleventy-plugin-minify?

在项目目录运行 npm install @codestitchofficial/eleventy-plugin-minify,或使用 pnpm add / yarn add / bun add。

@codestitchofficial/eleventy-plugin-minify 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/codestitchofficial__eleventy-plugin-minify 是否存在。

@codestitchofficial/eleventy-plugin-minify 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@codestitchofficial/eleventy-plugin-minify 可以商用吗?

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

@codestitchofficial/eleventy-plugin-minify 的下载量有多少?

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

@codestitchofficial/eleventy-plugin-minify 还在维护吗?

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