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 16, 2024
1 parent 2f9dd0e commit da57c8f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
3 changes: 1 addition & 2 deletions src/components/DevWarning.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import semver from 'semver'

export default class DevWarning extends Component {
render() {
// eslint-disable-next-line no-undef
const version = semver.parse(__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
9 changes: 3 additions & 6 deletions src/components/Footer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@ import { Component } from 'react'

export default class Footer extends Component {
render() {
// eslint-disable-next-line no-undef
const version = __DAKARA_VERSION__
// eslint-disable-next-line no-undef
const bugtracker = __DAKARA_BUGTRACKER__
// eslint-disable-next-line no-undef
const projectHomepage = __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: {
__DAKARA_VERSION__: JSON.stringify(packageJson.version),
__DAKARA_BUGTRACKER__: JSON.stringify(packageJson.bugs.url),
__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 da57c8f

Please sign in to comment.