-
Notifications
You must be signed in to change notification settings - Fork 785
/
vite.config.ts
45 lines (39 loc) · 1.05 KB
/
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
35
36
37
38
39
40
41
42
43
44
45
import path from 'path'
import vue from '@vitejs/plugin-vue'
import serveIndex from 'serve-index'
import type { Plugin } from 'vite'
import { defineConfig } from 'vite'
const examplesDir = path.resolve(__dirname, 'examples')
export default defineConfig({
root: examplesDir,
resolve: {
alias: {
'@interactjs/': path.resolve(__dirname, 'packages/@interactjs'),
interactjs: path.resolve(__dirname, 'packages/interactjs'),
},
},
define: {
...getDefinedEnv(),
},
plugins: [vue(), dirListing()],
optimizeDeps: {
include: ['react'],
},
server: {
port: 8081,
},
})
function getDefinedEnv () {
const entries = Object.entries(process.env)
.filter(([key]) => /^(NODE_ENV|npm_package_version|INTERACTJS_.*)$/.test(key))
.map(([key, value]) => [`process.env.${key}`, JSON.stringify(value)])
return Object.fromEntries(entries)
}
function dirListing (): Plugin {
return {
name: 'dir-listing',
configureServer (server) {
server.middlewares.use(serveIndex(examplesDir, { icons: true }) as any)
},
}
}