-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
34 lines (32 loc) · 883 Bytes
/
vite.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { sveltekit } from '@sveltejs/kit/vite';
import fs from 'fs';
import { defineConfig } from 'vitest/config';
import { sitemapPlugin } from './src/lib';
export default defineConfig({
plugins: [
sveltekit(),
sitemapPlugin(),
(() => {
const sitemapRoute = './src/sitemap.ts';
const update = () => {
let body = fs.readFileSync(sitemapRoute).toString();
if (!body.includes('@binsarjr/sveltekit-sitemap')) return;
body = body.replace('@binsarjr/sveltekit-sitemap', '$lib');
fs.writeFileSync(sitemapRoute, body);
};
return {
name: 'replace-dependencies-in-sitemap.ts',
configureServer(server) {
server.watcher
.add([sitemapRoute])
.on('add', update)
.on('ready', update)
.on('change', update);
}
};
})()
],
test: {
include: ['src/**/*.{test,spec}.{js,ts}', 'test/**/*.{test,spec}.{js,ts}']
}
});