its-personal/svelte.config.js

83 lines
2.4 KiB
JavaScript
Raw Normal View History

import adapter from '@sveltejs/adapter-cloudflare';
2023-11-01 23:36:58 +00:00
import { vitePreprocess } from '@sveltejs/kit/vite';
import preprocess from 'svelte-preprocess';
import path from 'path';
// import { mdsvexGlobalComponents } from './src/lib/utils/mdsvexGlobalComponents.js/index.js';
2023-11-01 23:36:58 +00:00
import { mdsvex } from 'mdsvex';
import mdsvexConfig from './mdsvex.config.js';
/* Not using
// import { mdsvexGlobalComponents } from './src/lib/utils/mdsvex-global-components.js';
2023-11-01 23:36:58 +00:00
/** @type {import('@sveltejs/kit').Config} */
const config = {
extensions: ['.svelte', ...(mdsvexConfig.extensions || [])],
2023-11-01 23:36:58 +00:00
// Consult https://kit.svelte.dev/docs/integrations#preprocessors
// for more information about preprocessors
preprocess: [
2023-11-01 23:36:58 +00:00
vitePreprocess(),
preprocess({
postcss: true
}),
// No neeed rn unless using mdsvex highlighter with svelte components
//mdsvexGlobalComponents({
// dir: `$lib/components/blog`,
// list: ['CodeFence.svelte'],
// extensions: ['.md']
// }),
mdsvex(mdsvexConfig)
2023-11-01 23:36:58 +00:00
],
2023-11-01 23:36:58 +00:00
vitePlugin: {
inspector: true
2023-11-01 23:36:58 +00:00
},
kit: {
// adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list.
// If your environment is not supported or you settled on a specific environment, switch out the adapter.
// See https://kit.svelte.dev/docs/adapters for more information about adapters.
adapter: adapter({}),
// sometimes problems with
2023-11-01 23:36:58 +00:00
alias: {
$lib: path.resolve('src', 'lib'),
$root: path.resolve('/'),
$src: path.resolve('src'),
2023-11-11 17:43:34 +00:00
$routes: path.resolve('src', 'routes'),
$content: path.resolve('src', 'content')
},
// TODO: FIX Banning external malware scripts for security and privacy of users, threw errors,
// csp: {
// directives: {
// 'script-src': ['self']
// },
// reportOnly: {
// 'script-src': ['self']
// }
// },
csrf: {
checkOrigin: process.env.NODE_ENV === 'development' ? false : true
2023-11-01 23:36:58 +00:00
},
prerender: {
crawl: true,
handleMissingId: 'warn',
handleHttpError: (details) => {
// Handle blog trying to prerender relative links that it can't
if (
details.status == 404 &&
details.path.startsWith('/blog') &&
details.referenceType == 'linked'
) {
console.warn(`PRERENDER ignored route ${details.path}`);
return;
}
2023-11-01 23:36:58 +00:00
throw new Error(`${details.status} ${details.path} from ${details.referrer}`);
}
}
2023-11-01 23:36:58 +00:00
}
};
export default config;