2023-11-11 15:23:04 +01:00
|
|
|
import { fileURLToPath, URL } from 'node:url'
|
2023-11-11 18:44:07 +01:00
|
|
|
import path from 'path'
|
2023-11-11 15:23:04 +01:00
|
|
|
|
|
|
|
import vue from '@vitejs/plugin-vue'
|
2023-11-11 18:44:07 +01:00
|
|
|
import { defineConfig } from 'vite'
|
2023-11-11 15:23:04 +01:00
|
|
|
|
2023-11-15 12:16:59 +01:00
|
|
|
const zxcvbnRe = /@zxcvbn-ts\/language-(\w+-?\w+?)\//
|
|
|
|
|
2023-11-11 15:23:04 +01:00
|
|
|
// https://vitejs.dev/config/
|
|
|
|
export default defineConfig({
|
|
|
|
plugins: [vue()],
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
|
|
|
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
|
|
|
'~@/scss': fileURLToPath(new URL('./src/scss', import.meta.url)),
|
2023-11-15 12:16:59 +01:00
|
|
|
'~@/assets': fileURLToPath(new URL('./src/assets', import.meta.url)),
|
|
|
|
},
|
2023-11-11 15:23:04 +01:00
|
|
|
},
|
|
|
|
server: {
|
2023-11-15 14:57:27 +01:00
|
|
|
host: true,
|
2023-11-15 12:16:59 +01:00
|
|
|
port: 3000,
|
2023-11-11 15:23:04 +01:00
|
|
|
},
|
|
|
|
build: {
|
|
|
|
outDir: path.resolve(__dirname, '../fittrackee/dist'),
|
|
|
|
emptyOutDir: true,
|
2023-11-15 12:16:59 +01:00
|
|
|
assetsDir: 'static',
|
|
|
|
rollupOptions: {
|
|
|
|
output: {
|
|
|
|
assetFileNames({ name }) {
|
|
|
|
if (name?.includes('pt-sans-v9-latin'))
|
|
|
|
return 'static/fonts/[name]-[hash][extname]'
|
|
|
|
if (name?.includes('.svg')) return 'static/img/[name]-[hash][extname]'
|
|
|
|
if (name?.includes('.css')) return 'static/css/[name]-[hash][extname]'
|
|
|
|
return 'static/[name]-[hash][extname]'
|
|
|
|
},
|
|
|
|
manualChunks: (id) => {
|
|
|
|
if (id.includes('@zxcvbn-ts/language-')) {
|
|
|
|
const matches = id.match(zxcvbnRe)
|
|
|
|
if (matches && matches.length === 2) {
|
|
|
|
return `password.${matches[1]}`
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (id.includes('node_modules')) {
|
|
|
|
if (
|
|
|
|
id.includes('/chart.js') ||
|
|
|
|
id.includes('/chartjs-plugin-datalabels')
|
|
|
|
)
|
|
|
|
return 'charts'
|
|
|
|
if (id.includes('/leaflet')) return 'maps'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2023-11-11 15:23:04 +01:00
|
|
|
})
|