Alias Plugin + Rollup + Typescript

Published: 29 November 2020
on channel: Svelte Mastery
5,262
61

If you try adding alias to your svelte + typescript project, you may run into a bug like..
[!] Error: Could not load ./src/myFly (imported by src/routes/Learn/Learn.svelte): ENOENT: no such file or directory, open './src/myFly' TL;DW 👇👇👇👇👇

1. npm i @rollup/plugin-alias -D

2. Add this to tsconfig.json
"compilerOptions": {
"baseUrl": ".",
"paths": {
"src/*": ["src/*"]
}
}

3. Add this AFTER the typescript plugin in rollup.config.js
alias({
resolve: ['.js', '.ts', '.svelte'],
entries: [
{ find: 'src', replacement: './src' },
]
}),

and don't forget to import it in rollup.config.js too
import alias from '@rollup/plugin-alias';


On this page of the site you can watch the video online Alias Plugin + Rollup + Typescript with a duration of hours minute second in good quality, which was uploaded by the user Svelte Mastery 29 November 2020, share the link with friends and acquaintances, this video has already been watched 5,262 times on youtube and it was liked by 61 viewers. Enjoy your viewing!