{"id":18862782,"url":"https://github.com/eik-lib/postcss-plugin","last_synced_at":"2026-04-02T17:03:14.432Z","repository":{"id":37017407,"uuid":"290311059","full_name":"eik-lib/postcss-plugin","owner":"eik-lib","description":"PostCSS plugin to do build-time import mapping using Eik","archived":false,"fork":false,"pushed_at":"2026-03-28T20:50:21.000Z","size":982,"stargazers_count":0,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-03-28T22:29:36.929Z","etag":null,"topics":["eik","eik-import-mapping","postcss-plugin"],"latest_commit_sha":null,"homepage":"https://eik.dev","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eik-lib.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2020-08-25T19:59:56.000Z","updated_at":"2026-03-28T20:50:23.000Z","dependencies_parsed_at":"2023-12-22T23:26:11.241Z","dependency_job_id":"f90f5e16-5689-4e54-b7d2-b2f8e15d6bb1","html_url":"https://github.com/eik-lib/postcss-plugin","commit_stats":null,"previous_names":["eik-lib/postcss-import-map"],"tags_count":55,"template":false,"template_full_name":null,"purl":"pkg:github/eik-lib/postcss-plugin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eik-lib%2Fpostcss-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eik-lib%2Fpostcss-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eik-lib%2Fpostcss-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eik-lib%2Fpostcss-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eik-lib","download_url":"https://codeload.github.com/eik-lib/postcss-plugin/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eik-lib%2Fpostcss-plugin/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31311028,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-02T12:59:32.332Z","status":"ssl_error","status_checked_at":"2026-04-02T12:54:48.875Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["eik","eik-import-mapping","postcss-plugin"],"created_at":"2024-11-08T04:35:42.926Z","updated_at":"2026-04-02T17:03:14.382Z","avatar_url":"https://github.com/eik-lib.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @eik/postcss-plugin\n\nPostCSS [Eik](https://eik.dev/) plugin to support the use of import maps to map \"bare\" import specifiers in CSS @import rules.\n\n## Installation\n\n```bash\n$ npm install @eik/postcss-plugin\n```\n\n## Usage\n\n```js\nconst postcss = require('postcss');\nconst plugin = require('@eik/postcss-plugin');\nconst fs = require('fs');\n\n// CSS to be processed\nconst css = fs.readFileSync('css/input.css', 'utf8');\n\npostcss()\n    .use(plugin())\n    .process(css, {\n        // `from` option is needed here\n        from: 'css/input.css',\n    })\n    .then(function (result) {\n        console.log(result.css);\n    });\n```\n\n## Description\n\nThis plugin transforms \"bare\" import specifiers to absolute URL specifiers in\nCSS modules by applying an Import Map ahead of time.\n\nFor a more detailed description of Import Maps, please see our [Import Maps section](https://eik.dev/docs/mapping_import_map).\n\nThe main target for Import Maps is to map import statements in EcmaScript Modules but it can be applied to CSS import statements too.\n\nGiven the following CSS:\n\n```css\n@import 'normalize.css';\n\nbody {\n    background: black;\n}\n```\n\nwhen applaying the following Import Map:\n\n```json\n{\n    \"imports\": {\n        \"normalize.css\": \"https://cdn.eik.dev/normalize.css@8/normalize.css\"\n    }\n}\n```\n\none will get a transformed CSS like so:\n\n```css\n@import 'https://cdn.eik.dev/normalize.css@8/normalize.css';\n\nbody {\n    background: black;\n}\n```\n\n## Options\n\nThis plugin takes the following as options:\n\n| option | default         | type     | required | details                                                                       |\n| ------ | --------------- | -------- | -------- | ----------------------------------------------------------------------------- |\n| path   | `process.cwd()` | `string` | `false`  | Path to directory containing a eik.json file or package.json with eik config. |\n| urls   | `[]`            | `array`  | `false`  | Array of import map URLs to fetch from.                                       |\n| maps   | `[]`            | `array`  | `false`  | Array of import map as objects.                                               |\n\nThe plugin will attempt to read import map URLs from [`eik.json` or `package.json`](https://eik.dev/docs/overview_eik_json) files in the root of the current working directory if present.\n\n```js\npostcss()\n    .use(\n        plugin()\n    )\n    .process(css, {...})\n    .then(...);\n```\n\nThe path to the location of an `eik.json` file can be specified with the `path` option.\n\n```js\npostcss()\n    .use(\n        plugin({ path: '/path/to/eik-json-folder' })\n    )\n    .process(css, {...})\n    .then(...);\n```\n\nThe plugin can also be told which URLs to load import maps from directly using the `urls` option.\n\n```js\npostcss()\n    .use(\n        plugin({ urls: 'http://myserver/import-map' })\n    )\n    .process(css, {...})\n    .then(...);\n```\n\nAdditionally, individual mappings can be specified using the `maps` option.\n\n```js\npostcss()\n    .use(\n        plugin({\n            maps: [{\n                \"imports\": {\n                    \"normalize.css\": \"https://cdn.eik.dev/normalize.css@8/normalize.css\",\n                },\n            }],\n        })\n    )\n    .process(css, {...})\n    .then(...);\n```\n\n### Precedence\n\nIf several of the options are used, `maps` takes precedence over `urls` which takes precedence over values loaded from an `eik.json` or `package.json` file.\n\nie. in the following example\n\n```js\npostcss()\n    .use(\n        plugin({\n            path: '/path/to/eik-json-folder',\n            urls: ['http://myserver/import-map'],\n            maps: [{\n                \"imports\": {\n                    \"normalize.css\": \"https://cdn.eik.dev/normalize.css@8/normalize.css\",\n                },\n            }],\n        })\n    )\n    .process(css, {...})\n    .then(...);\n```\n\nAny import map URLs in `eik.json` will be loaded first, then merged with (and overridden if necessary by) the result of fetching from `http://myserver/import-map` before finally being merged with (and overriden if necessary by) specific mappings defined in `maps`.\n\n## PostCSS Import Usage\n\nIf you're using [postcss-import](https://github.com/postcss/postcss-import) make sure you update the `plugins` option.\n`postcss.config.js`\n\n```js\nmodule.exports = (ctx) =\u003e ({\n    plugins: [\n        require('@eik/postcss-plugin')(),\n        require('postcss-import')({\n            // It needs to be added here as well to ensure everything is mapped\n            plugins: [require('@eik/postcss-plugin')],\n        }),\n    ],\n});\n```\n\n## License\n\nCopyright (c) 2020 Finn.no\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feik-lib%2Fpostcss-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feik-lib%2Fpostcss-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feik-lib%2Fpostcss-plugin/lists"}