I use VUE 3 with Vite. I want to set correct path config for styles in .vue SFC files.
my-component.vue:
<template>...</template>
<style scoped>
.my-ele{
background-image: url("@/background.png");
}
</style>
In vite.config.js I have,
{
base: process.env.APP_ENV === 'development'? '/': '/dist/',
build: {
outDir: path.resolve(__dirname, './../dist'),
manifest: true,
target: 'es2018',
rollupOptions: {
input: '/main.js'
}
},
resolve: {
alias: {
vue: 'vue/dist/vue.esm-bundler.js',
'@':'/E:/www/Project-x/assets'
}
}
}
When I run Vite and inspect the code I see the path
background-image: url("/@fs/E:/www/Project-x/asset/background.png");
instead of the path with Vite server which needs to be:
background-image: url("http://localhost:3000/@fs/E:/www/Project-x/asset/background.png");
How can I configure the app?