{"id":18358837,"url":"https://github.com/uppercod/postcss-import","last_synced_at":"2025-04-10T03:04:22.697Z","repository":{"id":113251388,"uuid":"291291308","full_name":"UpperCod/postcss-import","owner":"UpperCod","description":null,"archived":false,"fork":false,"pushed_at":"2020-09-27T15:14:10.000Z","size":31,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-04-25T13:42:58.098Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/UpperCod.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":"2020-08-29T14:53:55.000Z","updated_at":"2020-09-27T15:14:12.000Z","dependencies_parsed_at":"2023-07-21T21:32:49.785Z","dependency_job_id":null,"html_url":"https://github.com/UpperCod/postcss-import","commit_stats":{"total_commits":25,"total_committers":1,"mean_commits":25.0,"dds":0.0,"last_synced_commit":"f45157a50f939580a6a84faa6568c7176f15a3ba"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":"UpperCod/pkg-base","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UpperCod%2Fpostcss-import","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UpperCod%2Fpostcss-import/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UpperCod%2Fpostcss-import/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UpperCod%2Fpostcss-import/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/UpperCod","download_url":"https://codeload.github.com/UpperCod/postcss-import/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239036164,"owners_count":19571454,"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":[],"created_at":"2024-11-05T22:19:42.605Z","updated_at":"2025-02-15T18:30:01.483Z","avatar_url":"https://github.com/UpperCod.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @uppercod/postcss-import\n\nresolves the `@import` and creates the `tree` property in the result object, which defines the imports.\n\n1. Import and know the imports associated with the CSS.\n2. [Group the import under an alias to compose CSS](#group-the-import-under-an-alias-to-compose-css).\n3. [Optimize parallel import](#optimization).\n4. Consume CSS from URL.\n\n## Install\n\n```\nnpm install @uppercod/postcss-import\n```\n\n## Usage\n\n```js\nimport postcss from \"postcss\";\nimport { pluginImport } from \"@uppercod/postcss-import\";\n\npostcss([pluginImport()]).process(`@import \"http://unpkg.com/example.css\";`, {\n    from: \"example.css\",\n});\n```\n\n## Options\n\nThe options are parameters that are mutable by the process that optimize the execution of this plugin, the plugin internally has a cache system to avoid multiple executions of postcss,\nto improve performance you can share this cache.\n\n```js\npluginImport({\n    /**\n     * Cache local processes, the process object can be\n     * shared between multiple instances\n     */\n    process: {},\n    /**\n     * Stores the paths of the local files imported by the process\n     */\n    imports: {},\n    /**\n     * Allows you to override the default module resolution process\n     * @param {string} id\n     * @param {string} importer\n     */\n    resolve(id, importer) {\n        return {\n            // module resolution id\n            id,\n            // read css\n            css: `.myCss{}`,\n            // skip the scan and add it to the top header as import\n            external: true,\n            // associate the import with a cache to avoid processing the content\n            cache: true,\n        };\n    },\n});\n```\n\n**You can customize the resolution and reuse the plugin resolver**, eg:\n\n```js\nimport { pluginImport, resolve } from \"@uppercod/postcss-import\";\n```\n\n## Optimization\n\n```js\nconst cache = {};\n\npostcss([pluginImport(cache)]).process(`@import \"./file.css\";`, {\n    from: \"a.css\",\n});\n\npostcss([pluginImport(cache)]).process(`@import \"./file.css\";`, {\n    from: \"b.css\",\n});\n\npostcss([pluginImport(cache)]).process(`@import \"./file.css\";`, {\n    from: \"c.css\",\n});\n```\n\nThe import plugin will run only once for the file `file.css`.\n\n## Group the import under an alias to compose CSS.\n\nspecial feature of this plugin that allows associating the import to a group, to be associated based on that group with other rules, eg:\n\n```scss\n@import \"https://cdn.jsdelivr.net/npm/bulma@0.9.0/css/bulma.min.css\" (as: bulma);\n\n.button {\n    @extend bulma.button, bulma.is-dark;\n    @extend bulma\"a button\";\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuppercod%2Fpostcss-import","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fuppercod%2Fpostcss-import","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuppercod%2Fpostcss-import/lists"}