|
|
|
import path from 'node:path'
|
|
|
|
import process from 'node:process'
|
|
|
|
import { setupVitePlugins } from 'build/plugins'
|
|
|
|
import type { ConfigEnv } from 'vite'
|
|
|
|
import { defineConfig, loadEnv } from 'vite'
|
|
|
|
|
|
|
|
import generateSitemap from 'vite-ssg-sitemap'
|
|
|
|
|
|
|
|
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')}/`,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
plugins: setupVitePlugins(viteEnv),
|
|
|
|
|
|
|
|
server: {
|
|
|
|
host: '0.0.0.0',
|
|
|
|
port: 3200,
|
|
|
|
},
|
|
|
|
|
|
|
|
optimizeDeps: {
|
|
|
|
include: [],
|
|
|
|
},
|
|
|
|
|
|
|
|
// https://github.com/vitest-dev/vitest
|
|
|
|
test: {
|
|
|
|
include: ['test/**/*.test.ts'],
|
|
|
|
environment: 'jsdom',
|
|
|
|
deps: {
|
|
|
|
inline: ['@vue', '@vueuse', 'vue-demi'],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// https://github.com/antfu/vite-ssg
|
|
|
|
ssgOptions: {
|
|
|
|
script: 'async',
|
|
|
|
formatting: 'minify',
|
|
|
|
crittersOptions: {
|
|
|
|
reduceInlineStyles: false,
|
|
|
|
},
|
|
|
|
onFinished() {
|
|
|
|
generateSitemap()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
ssr: {
|
|
|
|
// TODO: workaround until they support native ESM
|
|
|
|
noExternal: ['workbox-window', /vue-i18n/],
|
|
|
|
},
|
|
|
|
|
|
|
|
build: {
|
|
|
|
reportCompressedSize: false,
|
|
|
|
sourcemap: false,
|
|
|
|
commonjsOptions: {
|
|
|
|
ignoreTryCatch: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
})
|