// env.development.js
module.exports = {
fileName: 'logo_dev.png'
}
// env.production.js
module.exports = {
fileName: 'logo_prod.png'
}
// index.vue
<script>
import logoSrc from '@/assets/images/' + process.env.fileName
export default {
data () {
return {
logo: {
src: logoSrc,
}
}
},
</script>
Hey there, I'm exploring Nuxt js and facing a challenge. I want to dynamically import an image file based on the environment value when building it. Unfortunately, I encountered an error with the following code snippet.
import logoSrc from '@/assets/images/' + process.env.fileName
Is there a way to dynamically import an image file using an env variable? If so, do you know of any helpful solutions or workarounds? Thanks in advance!