[Question] Aliasing SvelteKit paths
See original GitHub issueI’d like to use Svelte component testing feature in order to sort of unit test some ts libraries used across my SvelteKit application. This way I could use Playwright for everything.
The problem I currently stumbled upon is as follows: path import convention $app/stores
doesn’t seem to resolve correctly, despite overriding config as suggested here:
...
ctViteConfig: {
resolve: {
alias: {
$app: resolve('playwright/mocks/app')
}
}
}
and ./playwright/mocks/app
containing stores.ts
:
import { readable } from 'svelte/store';
export const page = readable({});
What I’m getting is Error: Cannot find package '$app'
, and, while $lib
and other aliases are resolving correctly, my guess is that $app
cannot not be overwritten.
I’ve also tried to move mocks to other directory and resolving with a __dirname
with no avail so far. Any ideas?
Issue Analytics
- State:
- Created 9 months ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Make Pathing Easier with Aliases in SvelteKit - CodingCat.dev
Out of the box SvelteKit provides a $lib alias setup for the src/lib folder and a number of modules are available from $app...
Read more >Configuration • Docs • SvelteKit
An object containing zero or more aliases used to replace values in import ... The directory relative to paths.assets where the built JS...
Read more >How to import enum using path alias in Svelte Kit?
I have an interface that I can export and use without problem through the path alias. Importing an enum throws an error: Cannot...
Read more >Path aliases don't work in basic svelte-kit app : WEB-55303
Path aliases don't work in basic svelte-kit app · Open the attached project, npm i · Open file: src/lib/header/Header.svelte , try to import...
Read more >How do I have import file path aliases in svelte? : r/sveltejs
rollup alias is not working like I want it to I need a simple tutorial ... https://stackoverflow.com/questions/43281741/how-to-use-paths-in- ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Oh, didn’t you ask for a repo, did you? Minimum repro @ GH.
Thanks!
See this comment https://github.com/microsoft/playwright/issues/16787#issuecomment-1230857867 We may add better support once SvelteKit becomes stable (at least 1.0.0 release is published).