-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.js
More file actions
65 lines (62 loc) · 1.92 KB
/
Copy pathvite.config.js
File metadata and controls
65 lines (62 loc) · 1.92 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import { defineConfig } from 'vite'
import { fileURLToPath } from 'node:url'
import babel from '@rolldown/plugin-babel'
import { contentPlugin } from './tools/vite-plugin-content.js'
import { importmapPlugin } from './tools/vite-plugin-importmap.js'
import { nodeModulesPlugin } from './tools/vite-plugin-node-modules.js'
import { staticPagesPlugin } from './tools/vite-plugin-static-pages.js'
const resolve = p => fileURLToPath(new URL(p, import.meta.url))
export default defineConfig({
// app source (incl. index.html, preview.html, pages/) lives in src/;
// keep publicDir and the build output at the project root, outside it.
root: resolve('./src'),
publicDir: resolve('./public'),
plugins: [
nodeModulesPlugin(),
contentPlugin(),
importmapPlugin(),
staticPagesPlugin(),
babel({
presets: [['pota/babel-preset']],
}),
],
server: {
// docs generation depends on this exact origin — refuse to start
// on a drifted port (1341, …) when 1340 is already taken.
port: 1340,
strictPort: true,
open: '/',
// content markdown lives in the pota repo (documentation/content),
// outside this Vite root; allow the dev server to read it. The repo
// root is an ancestor of src/, so this covers project files too.
fs: { allow: [resolve('../..')] },
},
preview: {
port: 1341,
strictPort: true,
},
optimizeDeps: {
rolldownOptions: {
transform: {
jsx: { runtime: 'automatic', importSource: 'pota' },
},
},
},
build: {
target: 'esnext',
outDir: resolve('./dist'),
emptyOutDir: true, // outDir is outside root — opt in to emptying it
rollupOptions: {
// preview.html is the playground's sandbox iframe; without it
// as an explicit input it would be dropped from the build (and
// never get the importmap injected).
input: {
index: resolve('./src/index.html'),
preview: resolve('./src/preview.html'),
},
},
},
define: {
__HMR_CONFIG_NAME__: JSON.stringify('vite'),
},
})