-
Notifications
You must be signed in to change notification settings - Fork 1
/
islands.config.js
44 lines (41 loc) · 1.07 KB
/
islands.config.js
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
35
36
37
38
39
40
41
42
43
44
import { svelte } from '@sveltejs/vite-plugin-svelte';
import { defineConfig } from 'vite';
import fs from 'fs';
import { join } from 'path';
// TODO: could this be a Vite plugin?
export default defineConfig(async () => {
// TODO: improve logic, e.g. nested folders, Test.2.svelte
const islandsFolder = join(__dirname, 'src/lib/islands');
const islands = fs.readdirSync(islandsFolder);
const input = islands.reduce((acc, fileName) => {
const key = fileName.split('.')[0];
acc[key] = join(islandsFolder, fileName);
return acc;
}, {});
input['is-land'] = join(__dirname, 'node_modules/@11ty/is-land/is-land.js');
return {
build: {
lib: {
formats: ['es']
},
rollupOptions: {
// in Vite 3.2, potentially multiple entries instead
// https://github.com/vitejs/vite/pull/7047
input,
output: {
dir: 'static/__islands',
entryFileNames: '[name].js' // TODO: hash filenames?
}
}
},
// TODO: can we hook into SvelteKit somehow?
plugins: [
svelte({
compilerOptions: {
hydratable: true,
css: false
}
})
]
};
});