You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.4 KiB
TypeScript

1 year ago
import path from 'node:path'
import { setupVitePlugins } from 'build/plugins'
import type { ConfigEnv } from 'vite'
import { defineConfig, loadEnv } from 'vite'
1 year ago
import generateSitemap from 'vite-ssg-sitemap'
1 year ago
export default defineConfig(({ command, mode }: ConfigEnv) => {
const viteEnv = loadEnv(mode, process.cwd()) as unknown as ImportMetaEnv
return {
base: viteEnv.VITE_BASE_URL,
resolve: {
alias: {
'~/': `${path.resolve(__dirname, 'src')}/`,
'#/': `${path.resolve(__dirname, 'src/types')}/`,
1 year ago
},
},
1 year ago
plugins: setupVitePlugins(viteEnv),
1 year ago
server: {
host: '0.0.0.0',
port: 3200,
},
1 year ago
optimizeDeps: {
include: [],
},
1 year ago
// https://github.com/vitest-dev/vitest
test: {
include: ['test/**/*.test.ts'],
environment: 'jsdom',
deps: {
inline: ['@vue', '@vueuse', 'vue-demi'],
1 year ago
},
},
1 year ago
// https://github.com/antfu/vite-ssg
ssgOptions: {
script: 'async',
formatting: 'minify',
crittersOptions: {
reduceInlineStyles: false,
},
onFinished() {
generateSitemap()
1 year ago
},
},
ssr: {
// TODO: workaround until they support native ESM
noExternal: ['workbox-window', /vue-i18n/],
1 year ago
},
build: {
reportCompressedSize: false,
sourcemap: false,
commonjsOptions: {
ignoreTryCatch: false,
},
},
}
1 year ago
})