refactor: fuck vite defineConfig

This commit is contained in:
zyronon 2024-05-02 00:14:41 +08:00
parent ea37bb9dff
commit ca57625cea
2 changed files with 169 additions and 168 deletions

View File

@ -2,6 +2,7 @@ name: Docker Image CI
on: on:
push: push:
branches: [ 'dev' ]
tags: tags:
- v* - v*

View File

@ -7,22 +7,17 @@ import { fileURLToPath, URL } from 'node:url'
import { getLastCommit } from 'git-last-commit' import { getLastCommit } from 'git-last-commit'
import VueMacros from 'unplugin-vue-macros/vite' 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 const lifecycle = process.env.npm_lifecycle_event
// { export default defineConfig(() => {
// name: 'axios', let latestCommitHash = ''
// var: 'axios',
// path: 'https://lib.baomitu.com/axios/1.6.8/axios.min.js'
// },
export default defineConfig(async () => { return new Promise((resolve) => {
const latestCommitHash = await new Promise<string>((resolve) => { getLastCommit((err, commit) => {
return getLastCommit((err, commit) => (err ? 'unknown' : resolve(commit.shortHash))) if (!err) {
}) latestCommitHash = commit.shortHash
return { }
resolve({
base: './', base: './',
envDir: 'env', envDir: 'env',
plugins: [ plugins: [
@ -103,11 +98,6 @@ export default defineConfig(async () => {
// }, // },
// }), // }),
], ],
define: {
LATEST_COMMIT_HASH: JSON.stringify(
latestCommitHash + (process.env.NODE_ENV === 'production' ? '' : ' (dev)')
)
},
resolve: { resolve: {
alias: { alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)) '@': fileURLToPath(new URL('./src', import.meta.url))
@ -167,6 +157,11 @@ export default defineConfig(async () => {
}, },
assetsInlineLimit: 2048 assetsInlineLimit: 2048
}, },
define: {
LATEST_COMMIT_HASH: JSON.stringify(
latestCommitHash + (process.env.NODE_ENV === 'production' ? '' : ' (dev)')
)
},
esbuild: { esbuild: {
// drop: ['console', 'debugger'] // drop: ['console', 'debugger']
}, },
@ -177,6 +172,11 @@ export default defineConfig(async () => {
fs: { fs: {
strict: false strict: false
} }
},
preview: {
port: 5555
} }
} })
})
})
}) })