fix(build): 为构建资源添加发布版本标识
This commit is contained in:
+31
-13
@@ -3,21 +3,39 @@ import { fileURLToPath, URL } from 'node:url'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import { defineConfig } from 'vite'
|
||||
|
||||
function resolveBuildId() {
|
||||
const configured = process.env.BUILD_ID?.trim().replace(/[^a-zA-Z0-9_-]/g, '')
|
||||
return configured || Date.now().toString(36)
|
||||
}
|
||||
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [vue()],
|
||||
server: {
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'https://ipad.shenynet.com',
|
||||
changeOrigin: true,
|
||||
secure: true,
|
||||
export default defineConfig(() => {
|
||||
const buildId = resolveBuildId()
|
||||
|
||||
return {
|
||||
plugins: [vue()],
|
||||
build: {
|
||||
rollupOptions: {
|
||||
output: {
|
||||
entryFileNames: `assets/[name]-${buildId}-[hash].js`,
|
||||
chunkFileNames: `assets/[name]-${buildId}-[hash].js`,
|
||||
assetFileNames: `assets/[name]-${buildId}-[hash][extname]`,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
||||
server: {
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'https://ipad.shenynet.com',
|
||||
changeOrigin: true,
|
||||
secure: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
||||
},
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user