astro
astro copied to clipboard
🐛 BUG: Build fails because Vue Component cannot access the value set in vite define
What version of astro
are you using?
1.0.0-beta.47
Are you using an SSR adapter? If so, which one?
None
What package manager are you using?
npm
What operating system are you using?
mac
Describe the Bug
Build fails because Vue Component cannot access the value set in vite define.
Works OK for astro dev
.
It is also OK if the vite define value is accessed from an Astro component.

Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-njhw7j-328yrx?file=astro.config.mjs&file=src%2Fcomponents%2FSample.vue&file=src%2Fpages%2Findex.astro
Participation
- [ ] I am willing to submit a pull request for this issue.
I don't think Astro actually supports Vite's define
config today, but need to confirm
In the meantime, as a workaround could something similar be done by importing a src/constants.js
file or adding a script to the main layout similar to the example below?
---
const VERSION = '1.0.0';
---
<script define:vars={{ VERSION }}>
window.__VERSION__ = VERSION;
</script>
To add to this, as there may be a difference in perception, you can refer to the value of Vite's define if it is within the Astro Component. The problem is that you cannot access it from the Vue Component.