You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i just upgrade from vue2 to vue3.
in vue2. i set a proxy entry /image in devServer to proxy all images from a remote cdn.
and then i uses all images in css background: url(/image/xxx) works just fine.
but in vue3. same code reports : Module not found: Error: Can't resolve '/image/xxx'
i'm using root url /image/xxx so base on the doc i think it should be kept as original string so when i visit the site i can get this image through proxy.
but seem now vue want to find out the image when run serve or run build and it doesn't go throught proxy so the image not found?
how can i solve this issue?
---------------------------- chinese translate ---------------------------------
目前我在使用 devServer 的 proxy 来代理我的图片资源,图片资源的url 以 /image 开头。在代码里(通常是 css)我使用 url(/image/xxx) 来访问图片
在 vue2 中这样做是没有任何问题的,感觉所有的 /image/xxx 都保留到了编译后的网站里,从而通过我设置的 proxy 成功获取到了图片。
但在 vue3 中 npm run serve 或者 npm run build 都报错 Module not found: Error: Can't resolve '/image/xxx' , 看起来是在编译时就试图引入图片,但没有通过proxy所以获取不到。 有任何解决方法吗?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
okay, i find out by my self.
just add
css: { loaderOptions: { css: { url: false } } },to vue.config.js