-
tags: [sveltekit, typeScript]
|
Beta Was this translation helpful? Give feedback.
Answered by
jeblister
Mar 13, 2023
Replies: 1 comment
-
You have to update two configs: Here is an example of // tsconfig.json
{
"extends": "./.svelte-kit/tsconfig.json",
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": false,
// Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias
"paths": {
"$src": ["./src"],
"$src/*": ["./src/*"],
"$lib": ["./src/lib"],
"$lib/*": ["./src/lib/*"]
}
}
} // svelte.config.js
import adapter from '@sveltejs/adapter-auto';
import { vitePreprocess } from '@sveltejs/kit/vite';
import { mdsvex } from 'mdsvex';
import mdsvexConfig from './mdsvex.config.js';
import path from 'path';
/** @type {import('@sveltejs/kit').Config} */
const config = {
// Consult https://kit.svelte.dev/docs/integrations#preprocessors
// for more information about preprocessors
extensions: ['.svelte', ...mdsvexConfig.extensions],
preprocess: [vitePreprocess(), mdsvex(mdsvexConfig)],
kit: {
adapter: adapter(),
alias: {
$src: path.resolve('./src'),
$lib: path.resolve('./src/lib')
}
}
};
export default config; You can modify them according to your needs and preferences. Resources :
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
jeblister
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You have to update two configs:
tsconfig
andsvelte.config.js
to define path aliases in SvelteKit. You can use the$lib
alias that is provided by SvelteKit by default or create your own aliases.Here is an example of
tsconfig.json
andsvelte.config.js
, those files are based on the (1) and (2) sources below: