{"id":19749336,"url":"https://github.com/lucagoslar/svelte-preprocess-sass-alias-import","last_synced_at":"2026-04-17T01:02:16.187Z","repository":{"id":57689478,"uuid":"469883059","full_name":"lucagoslar/svelte-preprocess-sass-alias-import","owner":"lucagoslar","description":"🗃 Import external stylesheets with the help of absolute paths.","archived":false,"fork":false,"pushed_at":"2023-01-20T18:15:24.000Z","size":146,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-03T10:08:50.655Z","etag":null,"topics":["absolute","alias","import","sass","scss","svelte-preprocess","sveltekit"],"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/lucagoslar.png","metadata":{"files":{"readme":"README.md","changelog":null,"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-03-14T19:50:05.000Z","updated_at":"2023-05-24T11:59:36.000Z","dependencies_parsed_at":"2023-02-12T04:17:23.362Z","dependency_job_id":null,"html_url":"https://github.com/lucagoslar/svelte-preprocess-sass-alias-import","commit_stats":null,"previous_names":["lucagoslar/sveltekit-sass-alias-import"],"tags_count":2,"template":false,"template_full_name":"lucagoslar/ts-pkg","purl":"pkg:github/lucagoslar/svelte-preprocess-sass-alias-import","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucagoslar%2Fsvelte-preprocess-sass-alias-import","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucagoslar%2Fsvelte-preprocess-sass-alias-import/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucagoslar%2Fsvelte-preprocess-sass-alias-import/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucagoslar%2Fsvelte-preprocess-sass-alias-import/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lucagoslar","download_url":"https://codeload.github.com/lucagoslar/svelte-preprocess-sass-alias-import/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucagoslar%2Fsvelte-preprocess-sass-alias-import/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268532747,"owners_count":24265435,"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","status":"online","status_checked_at":"2025-08-03T02:00:12.545Z","response_time":2577,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["absolute","alias","import","sass","scss","svelte-preprocess","sveltekit"],"created_at":"2024-11-12T02:26:05.301Z","updated_at":"2026-04-17T01:02:16.109Z","avatar_url":"https://github.com/lucagoslar.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## svelte-preprocess-sass-alias-import\n\n🗃 Import external stylesheets with the help of absolute paths.\n\nThough this package might also work in a different environment that uses sass, it should be noted that it serves the [legacy importer](https://sass-lang.com/documentation/js-api/modules#LegacyImporter) used by [svelte-preprocess](https://github.com/sveltejs/svelte-preprocess).\n\n[![build and test](https://github.com/lucagoslar/svelte-preprocess-sass-alias-import/actions/workflows/main.yml/badge.svg)](https://github.com/lucagoslar/svelte-preprocess-sass-alias-import/actions/workflows/main.yml)\n\n## Setup\n\n1. Import `SassAlias` from `svelte-preprocess-sass-alias-import`.\n\n```ts\nimport { SassAlias } from 'svelte-preprocess-sass-alias-import';\n```\n\n2. Instantiate `SassAlias` and pass it an object containing your rules.\n\n```ts\nconst alias = new SassAlias({\n\t$var: 'src/scss',\n  @var: [\"src\", \"scss\"]\n});\n```\n\n3. Add and bind the `SassAlias` instance to the project's preprocessor.\n   (Sample usage with SvelteKit.)\n\n```js\n// svelte.config.js\nimport preprocess from 'svelte-preprocess';\n\n/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n\tpreprocess: [\n\t\tpreprocess({\n\t\t\tsass: {\n\t\t\t\timporter: [alias.resolve.bind(alias)],\n\t\t\t},\n\t\t\tscss: {\n\t\t\t\timporter: [alias.resolve.bind(alias)],\n\t\t\t}, // Use for both sass and or scss\n\t\t}),\n\t],\n};\n\nexport default config;\n```\n\n```ts\n// vite.config.ts\n// Only required if you want to import stylesheets into an already imported stylesheet\n\nconst config: UserConfig = {\n\tcss: {\n\t\tpreprocessorOptions: {\n\t\t\tsass: {\n\t\t\t\timporter: [alias.resolve.bind(alias)],\n\t\t\t},\n\t\t\tscss: {\n\t\t\t\timporter: [alias.resolve.bind(alias)],\n\t\t\t},\n\t\t},\n\t},\n};\n```\n\n4. Import files using your predefined aliases.\n\n```svelte\n\u003c!-- *.svelte --\u003e\n\u003cstyle lang=\"scss\"\u003e\n  @import \"$var/main.scss\";\n\u003c/style\u003e\n```\n\n```svelte\n\u003c!-- *.svelte --\u003e\n\u003cstyle lang=\"sass\"\u003e\n  @use \"@var/main.scss\"\n\u003c/style\u003e\n```\n\n```scss\n// *.scss\n@use '@var/main.scss';\n```\n\n## Contribute\n\nInstall all (dev-)dependencies by running the following.\n\n```\n  npm i\n```\n\nMake sure [husky](https://github.com/typicode/husky) is being installed too.\n\n```\n  npm run prepare\n```\n\n\\\n_And off we go …_\n\nBuild this project with the following.\n\n```\nnpm run build\n```\n\nContributions of any kind are very much appreciated.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucagoslar%2Fsvelte-preprocess-sass-alias-import","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flucagoslar%2Fsvelte-preprocess-sass-alias-import","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucagoslar%2Fsvelte-preprocess-sass-alias-import/lists"}