mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-19 07:26:50 +00:00
refactor: improve version management
- Move version number from env to package.json - Add dynamic version loading with fallback - Improve error handling for version loading
This commit is contained in:
@@ -548,7 +548,15 @@ const BLOG = {
|
||||
process.env.npm_lifecycle_event === 'export', // 在打包过程中默认开启缓存,开发或运行时开启此功能意义不大。
|
||||
isProd: process.env.VERCEL_ENV === 'production' || process.env.EXPORT, // distinguish between development and production environment (ref: https://vercel.com/docs/environment-variables#system-environment-variables)
|
||||
BUNDLE_ANALYZER: process.env.ANALYZE === 'true' || false, // 是否展示编译依赖内容与大小
|
||||
VERSION: process.env.NEXT_PUBLIC_VERSION // 版本号
|
||||
VERSION: (() => {
|
||||
try {
|
||||
// 优先使用环境变量,否则从package.json中获取版本号
|
||||
return process.env.NEXT_PUBLIC_VERSION || require('./package.json').version
|
||||
} catch (error) {
|
||||
console.warn('Failed to load package.json version:', error)
|
||||
return '1.0.0' // 缺省版本号
|
||||
}
|
||||
})()
|
||||
}
|
||||
|
||||
module.exports = BLOG
|
||||
|
||||
Reference in New Issue
Block a user