You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
svelte/sites/svelte.dev/vite.config.js

37 lines
821 B

import { sveltekit } from '@sveltejs/kit/vite';
import * as fs from 'fs';
import { imagetools } from 'vite-imagetools';
process.env.VITE_API_BASE = process.env.DOCS_PREVIEW
? 'http://localhost:8787'
: 'https://api.svelte.dev';
function raw(ext) {
return {
name: 'vite-plugin-raw',
transform(_, id) {
if (ext.some((e) => id.endsWith(e))) {
const buffer = fs.readFileSync(id);
return { code: `export default ${JSON.stringify(buffer)}`, map: null };
}
}
};
}
/** @type {import('vite').UserConfig} */
const config = {
logLevel: 'info',
plugins: [raw(['.ttf']), imagetools(), sveltekit()],
optimizeDeps: {
exclude: ['@sveltejs/site-kit', '@sveltejs/repl']
},
ssr: { noExternal: ['@sveltejs/site-kit', '@sveltejs/repl'] },
server: {
fs: {
strict: false
}
}
};
export default config;