Skip to content
Mambo edited this page May 23, 2025 · 1 revision

프로그레시브 웹 앱(PWA)에서 버전 표시는 어떻게 할까? 일단, 매니패스트 파일에는 버전 항목이 없다.

.env 파일에서 package.json.version 참조

VITE_APP_VERSION=$npm_package_version

.vite.config.js 파일에서 git commit hash 참조

import { execSync } from 'child_process';

export default defineConfig(() => {
  return {
    define: {
      GIT_COMMIT_HASH: JSON.stringify(execSync('git rev-parse --short HEAD', { encoding: 'utf-8' })),
      BUILD_TIME: JSON.stringify(new Date().toISOString()),
    }
  }
})

Clone this wiki locally