-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.js
45 lines (39 loc) · 1.08 KB
/
vite.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
45
import { resolve } from 'path';
import fs from 'fs';
import kirby from 'vite-plugin-kirby';
const root = 'src';
const templateDir = resolve(__dirname, `${root}/templates`);
const templates = fs
.readdirSync(templateDir)
.filter((file) => !/^\./.test(file))
.filter((file) => fs.statSync(`${templateDir}/${file}`).isDirectory());
const input = Object.fromEntries([
...templates.map((template) => [
template,
`${templateDir}/${template}/index.js`,
]),
['shared', resolve(__dirname, `${root}/app.js`)],
]);
export default ({ mode }) => ({
root: 'src',
base: mode === 'development' ? '/' : '/dist/',
resolve: {
alias: [{ find: '@', replacement: resolve(__dirname, 'src') }],
},
build: {
outDir: resolve(process.cwd(), 'public/dist'),
assetsDir: 'assets',
emptyOutDir: true,
rollupOptions: { input },
},
plugins: [
kirby({
watch: [
'../content/**/*',
'../site/(templates|snippets|controllers|models|plugins)/**/*.php',
'../site/blueprints/**/*.yml',
],
kirbyConfigDir: 'site/config',
}),
],
});