I am porting a lot of php projects to vue3 at the moment. But I have difficulties with images I dont have locally and webpack refuses to work. I do not want to download 1000+ images and put them in my assets/images folder. They are available remote.
error:
This dependency was not found:
* @/img/backgrounds/background.png in ./node_modules/css-loader/...
Simple example:
<template>
// awesome vue template
</template>
<script lang="ts">
// awesome vue code
</script>
<style scoped lang="scss">
#awesome-container {
/* webpack says no */
background-image: url('~@/img/background.png');
}
</style>
folder structure remote:
/api/ <--- php stuff
/img/ <--- merged with the img from vue, but has a lot more folders and images
/css/ <--- from vue
/fonts/ <--- from vue
/... more vue folders .../
/index.html
Currently I help myself with using url('https://<ip-address-x>/img/background.png'). The vue3 will be deployed to https://<ip-address-x>/.
Is it possible to have an alias (like the paths in tsconfig) to tell webpack he has to use PATH_A in dev and PATH_B in prod?
It is highly possible we will use a cdn in a few month and it would be cool to just change one variable then instead of going trough 100+ files. The best thing would be, if I can keep the url('~@/img/background.png'); (or any other alias) and webpack/vue know where the files are.