Skip to content

Commit

Permalink
vite: inject DAKARA_* variables into import.meta.env
Browse files Browse the repository at this point in the history
  • Loading branch information
NextFire committed Mar 24, 2024
1 parent a68093d commit 8d983d5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/components/DevWarning.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import semver from 'semver'

export default class DevWarning extends Component {
render() {
const version = semver.parse(process.env.DAKARA_VERSION)
const version = semver.parse(import.meta.env.DAKARA_VERSION)

if (version.prerelease.length > 0) {
console.warn('You are running a dev version, use it at your own risks!')
Expand Down
6 changes: 3 additions & 3 deletions src/components/Footer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import React, { Component } from 'react'

export default class Footer extends Component {
render() {
const version = process.env.DAKARA_VERSION
const bugtracker = process.env.DAKARA_BUGTRACKER
const projectHomepage = process.env.DAKARA_PROJECT_HOMEPAGE
const version = import.meta.env.DAKARA_VERSION
const bugtracker = import.meta.env.DAKARA_BUGTRACKER
const projectHomepage = import.meta.env.DAKARA_PROJECT_HOMEPAGE

return (
<footer id="footer" className="box">
Expand Down
6 changes: 3 additions & 3 deletions vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ export default defineConfig({
},
},
define: {
'process.env.DAKARA_VERSION': JSON.stringify(packageJson.version),
'process.env.DAKARA_BUGTRACKER': JSON.stringify(packageJson.bugs.url),
'process.env.DAKARA_PROJECT_HOMEPAGE': JSON.stringify(packageJson.homepage),
'import.meta.env.DAKARA_VERSION': JSON.stringify(packageJson.version),
'import.meta.env.DAKARA_BUGTRACKER': JSON.stringify(packageJson.bugs.url),
'import.meta.env.DAKARA_PROJECT_HOMEPAGE': JSON.stringify(packageJson.homepage),
},
});

0 comments on commit 8d983d5

Please sign in to comment.