export const ssr = true;
export const csr = false;
export const prerender = true; //ex 'auto', true, false
prerender ture 시

output 폴더에 prerender에 생성
새로고침 할때 마다 변경
ex
routes/api/current-time/current-time.js
export async function GET() {
return new Response(new Date().toLocaleTimeString());
}
export const prerender = true;
+page.js
export const load = async ({ fetch }) => {
console.log('Loading');
const res = await fetch('/api/current-time');
const currentTime = await res.text();
return { currentTime };
};
export const prerender = true;
+page.svelte
<script>
import { goto, preloadData, preloadCode } from '$app/navigation';
export let data;
</script>
<style>
</style>
<p>
{data.currentTime}
</p>
dynamic routes 적용시 사전 파일 생성 됨.
const config = {
// Consult https://kit.svelte.dev/docs/integrations#preprocessors
// for more information about preprocessors
kit: {
adapter: adapter({
// see the 'Deployment configuration' section below
}),
prerender: {
// default: true,
crawl: true,
entries: ['/'],
},
},
preprocess: [
vitePreprocess(),
preprocess({
defaults: {
style: 'postcss',
},
postcss: {
plugins: [tailwind, autoprefixer],
},
}),
],
};