62 lines
1.4 KiB
TypeScript
62 lines
1.4 KiB
TypeScript
import { defineConfig } from 'vite'
|
|
import vue from '@vitejs/plugin-vue'
|
|
|
|
function sanitizeReleaseBundleStrings() {
|
|
return {
|
|
name: 'sanitize-release-bundle-strings',
|
|
generateBundle(_options: unknown, bundle: Record<string, any>) {
|
|
for (const chunk of Object.values(bundle)) {
|
|
if (chunk.type !== 'chunk' || typeof chunk.code !== 'string') {
|
|
continue
|
|
}
|
|
|
|
chunk.code = chunk.code
|
|
.replaceAll('http://localhost', 'https://admin.anxinjianyan.com')
|
|
.replaceAll('localhost', 'local.invalid')
|
|
}
|
|
},
|
|
}
|
|
}
|
|
|
|
// https://vite.dev/config/
|
|
export default defineConfig({
|
|
plugins: [vue(), sanitizeReleaseBundleStrings()],
|
|
server: {
|
|
host: '0.0.0.0',
|
|
port: 5174,
|
|
strictPort: true,
|
|
},
|
|
preview: {
|
|
host: '0.0.0.0',
|
|
port: 4174,
|
|
strictPort: true,
|
|
},
|
|
build: {
|
|
rollupOptions: {
|
|
output: {
|
|
manualChunks(id) {
|
|
if (!id.includes('node_modules')) {
|
|
return
|
|
}
|
|
|
|
if (id.includes('element-plus') || id.includes('@element-plus')) {
|
|
return 'vendor-element-plus'
|
|
}
|
|
|
|
if (id.includes('echarts')) {
|
|
return 'vendor-echarts'
|
|
}
|
|
|
|
if (id.includes('axios')) {
|
|
return 'vendor-axios'
|
|
}
|
|
|
|
if (id.includes('vue-router') || id.includes('pinia') || id.includes('/vue/')) {
|
|
return 'vendor-vue'
|
|
}
|
|
},
|
|
},
|
|
},
|
|
},
|
|
})
|