0
0
mirror of https://github.com/sveltejs/svelte.git synced 2024-11-29 16:36:44 +01:00
svelte/sites/svelte.dev/vite.config.js
Puru Vijay bb0d34bbd0
feat(site-2): Accessibility (#8579)
* Push

* Push

* Fix Contents order

* Skip link to left sidemenu

* Add text class

* use top-nav slot

* Improve imagetools

* Fix aria-label

* Bump site-kit
2023-05-16 20:48:44 +05:30

53 lines
1.1 KiB
JavaScript

import { sveltekit } from '@sveltejs/kit/vite';
import * as fs from 'fs';
process.env.VITE_API_BASE = process.env.DOCS_PREVIEW
? 'http://localhost:8787'
: 'https://api.svelte.dev';
const plugins = [raw(['.ttf']), sveltekit()];
// Only enable sharp if we're not in a webcontainer env
if (!process.versions.webcontainer) {
plugins.push(
(await import('vite-imagetools')).imagetools({
defaultDirectives: (url) => {
if (url.searchParams.has('big-image')) {
return new URLSearchParams('w=640;1280;2560;3840&format=avif;webp;png&as=picture');
}
return new URLSearchParams();
}
})
);
}
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,
optimizeDeps: {
exclude: ['@sveltejs/site-kit', '@sveltejs/repl']
},
ssr: { noExternal: ['@sveltejs/site-kit', '@sveltejs/repl'] },
server: {
fs: {
strict: false
}
}
};
export default config;