Files
qwerty-learner/vite.config.ts

35 lines
1.1 KiB
TypeScript

import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import jotaiDebugLabel from 'jotai/babel/plugin-debug-label'
import jotaiReactRefresh from 'jotai/babel/plugin-react-refresh'
import path from 'node:path'
import svgr from 'vite-plugin-svgr'
import { getLastCommit } from 'git-last-commit'
// https://vitejs.dev/config/
export default defineConfig(async () => {
const latestCommitHash = await new Promise<string>((resolve) => {
return getLastCommit((err, commit) => (err ? 'unknown' : resolve(commit.shortHash)))
})
return {
plugins: [react({ babel: { plugins: [jotaiDebugLabel, jotaiReactRefresh] } }), svgr()],
build: {
outDir: 'build',
},
define: {
REACT_APP_DEPLOY_ENV: JSON.stringify(process.env.REACT_APP_DEPLOY_ENV),
LATEST_COMMIT_HASH: JSON.stringify(latestCommitHash + (process.env.NODE_ENV === 'production' ? '' : ' (dev)')),
},
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
},
},
css: {
modules: {
localsConvention: 'camelCaseOnly',
},
},
}
})