refactor: fuck vite defineConfig
This commit is contained in:
parent
ea37bb9dff
commit
ca57625cea
1
.github/workflows/docker-image-ci.yml
vendored
1
.github/workflows/docker-image-ci.yml
vendored
@ -2,6 +2,7 @@ name: Docker Image CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ 'dev' ]
|
||||
tags:
|
||||
- v*
|
||||
|
||||
|
||||
@ -7,22 +7,17 @@ import { fileURLToPath, URL } from 'node:url'
|
||||
import { getLastCommit } from 'git-last-commit'
|
||||
import VueMacros from 'unplugin-vue-macros/vite'
|
||||
|
||||
// import viteImagemin from 'vite-plugin-imagemin'
|
||||
// import viteCompression from 'vite-plugin-compression'
|
||||
|
||||
const lifecycle = process.env.npm_lifecycle_event
|
||||
|
||||
// {
|
||||
// name: 'axios',
|
||||
// var: 'axios',
|
||||
// path: 'https://lib.baomitu.com/axios/1.6.8/axios.min.js'
|
||||
// },
|
||||
export default defineConfig(() => {
|
||||
let latestCommitHash = ''
|
||||
|
||||
export default defineConfig(async () => {
|
||||
const latestCommitHash = await new Promise<string>((resolve) => {
|
||||
return getLastCommit((err, commit) => (err ? 'unknown' : resolve(commit.shortHash)))
|
||||
})
|
||||
return {
|
||||
return new Promise((resolve) => {
|
||||
getLastCommit((err, commit) => {
|
||||
if (!err) {
|
||||
latestCommitHash = commit.shortHash
|
||||
}
|
||||
resolve({
|
||||
base: './',
|
||||
envDir: 'env',
|
||||
plugins: [
|
||||
@ -103,11 +98,6 @@ export default defineConfig(async () => {
|
||||
// },
|
||||
// }),
|
||||
],
|
||||
define: {
|
||||
LATEST_COMMIT_HASH: JSON.stringify(
|
||||
latestCommitHash + (process.env.NODE_ENV === 'production' ? '' : ' (dev)')
|
||||
)
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': fileURLToPath(new URL('./src', import.meta.url))
|
||||
@ -167,6 +157,11 @@ export default defineConfig(async () => {
|
||||
},
|
||||
assetsInlineLimit: 2048
|
||||
},
|
||||
define: {
|
||||
LATEST_COMMIT_HASH: JSON.stringify(
|
||||
latestCommitHash + (process.env.NODE_ENV === 'production' ? '' : ' (dev)')
|
||||
)
|
||||
},
|
||||
esbuild: {
|
||||
// drop: ['console', 'debugger']
|
||||
},
|
||||
@ -177,6 +172,11 @@ export default defineConfig(async () => {
|
||||
fs: {
|
||||
strict: false
|
||||
}
|
||||
},
|
||||
preview: {
|
||||
port: 5555
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Loading…
Reference in New Issue
Block a user