Skip to content

Commit ae8ea4a

Browse files
test: extend fixture. (#4)
1 parent 143cfd6 commit ae8ea4a

15 files changed

Lines changed: 3029 additions & 98 deletions

File tree

‎README.md‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,35 @@ export class ButtonWrapper extends LitElement {
144144

145145
The loader appends `export const reactStyles = "/* compiled css */"` to the module, so you can wire it directly into Lit’s `static styles` or any other runtime.
146146

147+
### Custom resolver (enhanced-resolve example)
148+
149+
If your project uses aliases or nonstandard resolution, plug in a custom resolver. Here’s how to use [`enhanced-resolve`](https://github.com/webpack/enhanced-resolve):
150+
151+
```ts
152+
import { ResolverFactory } from 'enhanced-resolve'
153+
import { css } from '@knighted/css'
154+
155+
const resolver = ResolverFactory.createResolver({
156+
extensions: ['.ts', '.tsx', '.js'],
157+
mainFiles: ['index'],
158+
})
159+
160+
async function resolveWithEnhanced(id: string, cwd: string): Promise<string | undefined> {
161+
return new Promise((resolve, reject) => {
162+
resolver.resolve({}, cwd, id, {}, (err, result) => {
163+
if (err) return reject(err)
164+
resolve(result ?? undefined)
165+
})
166+
})
167+
}
168+
169+
const styles = await css('./src/routes/page.tsx', {
170+
resolver: (specifier, { cwd }) => resolveWithEnhanced(specifier, cwd),
171+
})
172+
```
173+
174+
This keeps `@knighted/css` resolution in sync with your bundler’s alias/extension rules.
175+
147176
## Scripts
148177

149178
- `npm run build` – Produce CJS/ESM outputs via `@knighted/duel`.

0 commit comments

Comments
 (0)