{"id":15016528,"url":"https://github.com/5t3ph/eleventy-plugin-lightningcss","last_synced_at":"2025-04-12T09:30:42.106Z","repository":{"id":84250550,"uuid":"606516822","full_name":"5t3ph/eleventy-plugin-lightningcss","owner":"5t3ph","description":"Process CSS in Eleventy (11ty) with LightningCSS to minify, prefix, and add future CSS support.","archived":false,"fork":false,"pushed_at":"2024-04-07T17:56:22.000Z","size":158,"stargazers_count":39,"open_issues_count":5,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-26T04:33:32.115Z","etag":null,"topics":["11ty","11ty-plugin","eleventy","eleventy-plugin","lightningcss"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@11tyrocks/eleventy-plugin-lightningcss","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/5t3ph.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-25T18:18:32.000Z","updated_at":"2024-11-05T04:34:19.000Z","dependencies_parsed_at":"2024-01-17T02:34:31.765Z","dependency_job_id":"f94e181b-dbd2-481b-b545-d8fff1eaba6c","html_url":"https://github.com/5t3ph/eleventy-plugin-lightningcss","commit_stats":{"total_commits":9,"total_committers":1,"mean_commits":9.0,"dds":0.0,"last_synced_commit":"48e29447a6f255d6a65e524d0b13645957824617"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/5t3ph%2Feleventy-plugin-lightningcss","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/5t3ph%2Feleventy-plugin-lightningcss/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/5t3ph%2Feleventy-plugin-lightningcss/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/5t3ph%2Feleventy-plugin-lightningcss/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/5t3ph","download_url":"https://codeload.github.com/5t3ph/eleventy-plugin-lightningcss/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248545942,"owners_count":21122240,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["11ty","11ty-plugin","eleventy","eleventy-plugin","lightningcss"],"created_at":"2024-09-24T19:49:02.057Z","updated_at":"2025-04-12T09:30:41.759Z","avatar_url":"https://github.com/5t3ph.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Eleventy Plugin: LightningCSS\n\n\u003e Process CSS in Eleventy (11ty) with LightningCSS to minify, prefix, and add future CSS support.\n\nAlso respects either your package.json `browserslist` or a `.browserslistrc`, otherwise the default targets are `\u003e 0.2% and not dead`.\n\nReview [LightningCSS docs](https://lightningcss.dev/transpilation.html) to learn more about what future CSS features are supported via syntax lowering, including color functions, media query ranges, logical properties, and more.\n\n\u003e **Note**\n\u003e Requires Eleventy v2 - review [upgrade considerations](https://11ty.rocks/posts/new-features-upgrade-considerations-eleventy-version-2/) if applying to an existing project.\n\n\u003csmall\u003eIf you want Sass support as well, use my [Sass + LightningCSS plugin](https://github.com/5t3ph/eleventy-plugin-sass-lightningcss) instead!\u003c/small\u003e\n\n## Features\n\nLightningCSS minifies, prefixes, and enables transpiling based on your browserslist (or the included default) to gain future-CSS support today, with graceful upgrading as browser support improves.\n\nIt includes enables the following LightningCSS flags by default:\n\n- [bundling](https://lightningcss.dev/bundling.html) - enables including other files via the `@import` syntax\n- [nesting](https://lightningcss.dev/transpilation.html#nesting)\n- [minify](https://lightningcss.dev/minification.html)\n- [custom media queries](https://lightningcss.dev/transpilation.html#custom-media-queries)\n\n## Usage\n\nInstall the plugin package:\n\n```bash\nnpm install @11tyrocks/eleventy-plugin-lightningcss\n```\n\nThen, include it in your `.eleventy.js` config file:\n\n```js\nconst lightningCSS = require(\"@11tyrocks/eleventy-plugin-lightningcss\");\n\nmodule.exports = (eleventyConfig) =\u003e {\n  // If you already have a config, add just the following line\n  eleventyConfig.addPlugin(lightningCSS);\n};\n```\n\n⚠️ **Important**: The files will end up in `collections.all` and appear in places like RSS feeds where you may be using the \"all\" collection. To prevent that, [a temporary workaround](https://github.com/11ty/eleventy/discussions/2850#discussioncomment-5254892) is to create a directory data file to exclude your Sass files.\n\nPlace the following in the directory containing your Sass files. As an example, for a directory called `css` the file would be called `css/css.json`:\n\n```js\n{\n  \"eleventyExcludeFromCollections\": true\n}\n```\n\nThen, write your CSS using any organization pattern you like as long as it lives within your defined [Eleventy input directory](https://www.11ty.dev/docs/config/#input-directory).\n\n\u003e **Note**\n\u003e If you are already using PostCSS or Parcel, you will be doubling efforts with this plugin and should not add it.\n\n## Config Options\n\n### Base options\n\n| Option        | Type    | Default |\n| ------------- | ------- | ------- |\n| importPrefix  | string  | '\\_'    |\n| nesting       | boolean | true    |\n| customMedia   | boolean | true    |\n| minify        | boolean | true    |\n| sourceMap     | boolean | false   |\n| visitors      | array   | []      |\n| customAtRules | object  | {}      |\n\n### Bundling Import Prefix\n\nThe plugin defaults to setting up 11ty to ignore CSS filenames prefixed with `_` (configure with `importPrefix`) so that those files do not end up as separate stylesheets in your final build. That way you can signify which CSS files you are including via the `@import` syntax.\n\n### Extend LightningCSS with custom transforms\n\n- Pass an array to `visitors` to include your own [custom transform functions](https://lightningcss.dev/transforms.html).\n- Pass an object to `customAtRules` to [support your own at-rules](https://lightningcss.dev/transforms.html#custom-at-rules)\n\n#### Example: Support mixins and static variables\n\nExpand to see how to configure mixins and static variables as custom at-rules using the LightningCSS docs examples for [unknown and custom at-rules](https://lightningcss.dev/transforms.html#unknown-at-rules).\n\n\u003cdetails\u003e\n\u003csummary\u003eSupport mixins and static variables\u003c/summary\u003e\n\n```js\nlet declared = new Map();\nlet mixins = new Map();\n\nconst rules = {\n  Rule: {\n    unknown(rule) {\n      declared.set(rule.name, rule.prelude);\n      return [];\n    },\n    custom: {\n      mixin(rule) {\n        mixins.set(rule.prelude.value, rule.body.value);\n        return [];\n      },\n      apply(rule) {\n        return mixins.get(rule.prelude.value);\n      },\n    },\n  },\n};\n\nconst tokens = {\n  Token: {\n    \"at-keyword\"(token) {\n      return declared.get(token.value);\n    },\n  },\n};\n\nconst atRules = {\n  mixin: {\n    prelude: \"\u003ccustom-ident\u003e\",\n    body: \"style-block\",\n  },\n  apply: {\n    prelude: \"\u003ccustom-ident\u003e\",\n  },\n};\n\nmodule.exports = (eleventyConfig) =\u003e {\n  eleventyConfig.addPlugin(lightningCSS, {\n    customAtRules: atRules,\n    visitors: [rules, tokens],\n  });\n};\n```\n\n\u003c/details\u003e\n\n## How does it work?\n\nThis plugin uses Eleventy's `addTemplateFormats` and `addExtension` features to essentiallly recognize CSS as a first-class templating language, and add custom processing. Since it makes CSS into a templating language, changes are applied during local development hot-reloading without a delay or requiring a manual browser refresh.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F5t3ph%2Feleventy-plugin-lightningcss","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F5t3ph%2Feleventy-plugin-lightningcss","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F5t3ph%2Feleventy-plugin-lightningcss/lists"}