mirror of
https://github.com/sveltejs/svelte.git
synced 2024-11-30 00:46:29 +01:00
37 lines
821 B
JavaScript
37 lines
821 B
JavaScript
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;
|