You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/sass-import-aliases.md
+9-7Lines changed: 9 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,19 +1,22 @@
1
1
# Sass import aliases
2
2
3
-
Some Sass codebases rely on custom load-path prefixes such as `pkg:#ui/button` or `pkg:@scope/app/components/button`. Those specifiers are resolved by the Sass compiler itself—they never travel through Node.js resolution, `package.json#imports`, or tsconfig `paths`. Because `@knighted/css` reuses Node-style resolution rules underneath (`oxc-resolver`), it cannot interpret Sass-only prefixes automatically.
3
+
Some Sass codebases rely on custom load-path prefixes such as `pkg:#ui/button` or `alias:@scope/app/components/button`. Those specifiers are resolved by the Sass compiler itself—they never travel through Node.js resolution, `package.json#imports`, or tsconfig `paths`.
4
4
5
-
The fix is to provide a custom resolver that rewrites those specifiers into absolute paths before the loader (or the standalone `css()` function) tries to walk the dependency graph.
5
+
`@knighted/css` ships a built-in Sass importer for `pkg:` so `pkg:#...` specifiers resolve without any custom resolver. For any other bespoke scheme or alias, provide a custom resolver that rewrites the specifier into an absolute path before the loader (or the standalone `css()` function) walks the dependency graph.
6
+
7
+
> [!NOTE]
8
+
> Sass support is provided via Dart Sass (`sass` npm package). Ruby Sass and node-sass are not supported.
6
9
7
10
## When you need a resolver
8
11
9
12
Add a resolver whenever you see either of the following:
10
13
11
-
- An `@use`/`@import` statement that starts with a nonstandard scheme such as `pkg:` or `sass:`.
14
+
- An `@use`/`@import` statement that starts with a nonstandard scheme such as `alias:` or `sass:` (other than `pkg:`).
12
15
- A project-level shorthand that never appears in `package.json#imports` or `tsconfig.json` (for example, `@scope/app` pointing at a workspace directory only Sass knows about).
13
16
14
17
Without a resolver, those imports throw “Cannot resolve specifier” errors as soon as `@knighted/css` tries to crawl the module graph.
15
18
16
-
## Example: strip `pkg:#` aliases
19
+
## Example: strip custom aliases
17
20
18
21
```ts
19
22
importpathfrom'node:path'
@@ -22,10 +25,9 @@ import { css } from '@knighted/css'
Copy file name to clipboardExpand all lines: packages/css/package.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
{
2
2
"name": "@knighted/css",
3
-
"version": "1.1.0-rc.3",
3
+
"version": "1.1.0-rc.4",
4
4
"description": "A build-time utility that traverses JavaScript/TypeScript module dependency graphs to extract, compile, and optimize all imported CSS into a single, in-memory string.",
0 commit comments