{"id":15885749,"url":"https://github.com/metonym/svelte-preprocess-global","last_synced_at":"2026-04-29T02:43:10.764Z","repository":{"id":40308436,"uuid":"492591053","full_name":"metonym/svelte-preprocess-global","owner":"metonym","description":"Svelte preprocessor that applies the :global() directive to id, class, and data attribute selectors passed to Svelte components.","archived":false,"fork":false,"pushed_at":"2023-01-07T21:27:14.000Z","size":68,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-11T03:11:12.605Z","etag":null,"topics":["global","svelte","svelte-preprocessor"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/metonym.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-05-15T20:02:40.000Z","updated_at":"2022-07-16T16:57:34.000Z","dependencies_parsed_at":"2023-02-08T02:03:54.089Z","dependency_job_id":null,"html_url":"https://github.com/metonym/svelte-preprocess-global","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/metonym/svelte-preprocess-global","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metonym%2Fsvelte-preprocess-global","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metonym%2Fsvelte-preprocess-global/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metonym%2Fsvelte-preprocess-global/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metonym%2Fsvelte-preprocess-global/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/metonym","download_url":"https://codeload.github.com/metonym/svelte-preprocess-global/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metonym%2Fsvelte-preprocess-global/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263069031,"owners_count":23408886,"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":["global","svelte","svelte-preprocessor"],"created_at":"2024-10-06T05:07:20.069Z","updated_at":"2026-04-29T02:43:05.642Z","avatar_url":"https://github.com/metonym.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# svelte-preprocess-global\n\n\u003e Svelte preprocessor that applies the `:global()` directive to id, class, and data attribute selectors passed to Svelte components.\n\nBy design, Svelte styles are [component-scoped](https://svelte.dev/docs#component-format-style). The `:global(...)` directive is required to apply a style globally.\n\n`svelte-preprocess` already supports `\u003cstyle global\u003e`; however, it will apply the `:global` directive to _all_ selectors in the style block.\n\nInstead of making every selector global, this preprocessor only applies the `:global` directive to ids, classes, and data attributes passed to other Svelte components.\n\n**Input**\n\n```svelte\n\u003cComponent id=\"component\" data-component class=\"bg-blue\" /\u003e\n\n\u003cstyle\u003e\n  #component {\n    color: red;\n  }\n\n  [data-component] {\n    outline: 1px solid white;\n  }\n\n  .bg-blue {\n    background: blue;\n  }\n\u003c/style\u003e\n```\n\n**Output**\n\n```svelte\n\u003cComponent id=\"component\" data-component class=\"bg-blue\" /\u003e\n\n\u003cstyle\u003e\n  :global(#component) {\n    color: red;\n  }\n\n  :global([data-component]) {\n    outline: 1px solid white;\n  }\n\n  :global(.bg-blue) {\n    color: blue;\n  }\n\u003c/style\u003e\n```\n\nThe preprocessor can also detect `@keyframes` usage:\n\n**Input**\n\n```css\n.animate {\n  animation: fade 1.5s linear infinite;\n}\n\n@keyframes fade {\n  50% {\n    opacity: 0;\n  }\n}\n```\n\n**Output**\n\n```css\n:global(.animate) {\n  animation: fade 1.5s linear infinite;\n}\n\n@keyframes -global-fade {\n  50% {\n    opacity: 0;\n  }\n}\n```\n\n## Installation\n\n```bash\n# Yarn\nyarn add -D svelte-preprocess-global\n\n# NPM\nnpm i -D svelte-preprocess-global\n\n# pnpm\npnpm i -D svelte-preprocess-global\n```\n\n## Usage\n\nAdd `global` to the list of preprocessors in your `svelte.config.js`.\n\n```js\n// svelte.config.js\nimport { global } from \"svelte-preprocess-global\";\n\nconst config = {\n  preprocess: [global()],\n};\n\nexport default config;\n```\n\n## Changelog\n\n[CHANGELOG.md](CHANGELOG.md)\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetonym%2Fsvelte-preprocess-global","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmetonym%2Fsvelte-preprocess-global","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetonym%2Fsvelte-preprocess-global/lists"}