-
Notifications
You must be signed in to change notification settings - Fork 4
/
vite.config.mts
65 lines (61 loc) · 1.63 KB
/
vite.config.mts
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
/// <reference types="vitest" />
import path from 'node:path'
import { defineConfig, loadConfigFromFile, mergeConfig } from 'vite'
import { createHtmlPlugin } from 'vite-plugin-html'
import { i18nAlly } from 'vite-plugin-i18n-ally'
import { plugin as markdown, Mode } from 'vite-plugin-markdown'
import { DEV_PORT } from './src/meta'
export default defineConfig(async (env) => {
const loadResult = await loadConfigFromFile(
env,
path.resolve(__dirname, './src/webview/ui-framework/vite.config.mts'),
)
const config = defineConfig({
server: {
host: '0.0.0.0',
port: DEV_PORT,
watch: {},
hmr: {
host: 'localhost',
protocol: 'ws',
},
},
envPrefix: 'IM_',
preview: {
host: '0.0.0.0',
port: DEV_PORT,
},
plugins: [
createHtmlPlugin({
entry: path.resolve(__dirname, './src/webview/main.tsx'),
minify: env.command === 'build',
}),
i18nAlly({
root: __dirname,
localesPaths: [path.resolve(__dirname, './src/webview/locales')],
}),
markdown({ mode: [Mode.MARKDOWN] }),
],
optimizeDeps: {
force: true,
},
build: {
outDir: path.resolve(__dirname, './dist-webview/'),
emptyOutDir: true,
minify: true,
rollupOptions: {
treeshake: true,
output: {
entryFileNames: 'assets/[name].js',
chunkFileNames: 'assets/[name].js',
assetFileNames: 'assets/[name].[ext]',
},
},
target: 'es2020',
},
test: {
include: ['**/__test__/**/*.test.ts'],
},
})
return mergeConfig(loadResult!.config, config)
})