[Vuejs]-Using Vue£ Vite globalProperties in production?

0👍

Fixed the issue by using provide and inject to use then

// in main.js
app.provide("IMAGE_URL", import.meta.env.IMAGE_URL);
// in components script setup
import {inject} from 'vue'
const IMAGE_URL = inject("IMAGE_URL");
// in <img>
:src="`${IMAGE_URL}/path/to/asset`"

hope it helps !

Leave a comment