EvanAgee / vuejs-wordpress-theme-starter

A WordPress theme with the guts ripped out and replaced with Vue.
https://vuewp.com/
1.6k stars 281 forks source link

Assets URL rendering problem #6

Closed vksco closed 6 years ago

vksco commented 6 years ago

before mixing all the assets i used to put all images under src/assets/images/, after mixing all the images copied to dist/assets/, but wordpress theme could't get this image from its url i.e <img data-v-10e39ae0 src="/images/homelayer1-min.png?29a6a2fd8dadbdd1e9cd6b82fe8f22d5">.

the url should be <img data-v-10e39ae0 src="dist/assets/images/homelayer1-min.png?29a6a2fd8dadbdd1e9cd6b82fe8f22d5">

now how to resolve this image url problem?

EvanAgee commented 6 years ago

Hey @vikash2039 yeah I wrestled with this a little as well and ended up linking images relative to /wp-content using a JS variable. It's not the cleanest solution but it worked. I'm not a webpack guru but I'm sure there are other ways of handling it.

vksco commented 6 years ago

i dint think if it is a good idea for production environment..... i did a better solution for this but its only temporary. laravel-mix gives us support for adding 'resourceRoot' for our absolute assets like images, fonts ... change it with url of project , like 'http://localhost/project-name/wp-content/themes/theme-name/dist/', this will compaile all assets with this path.

another side,

developer can use wordpress backend to upload images and get url for the images.

but as i said its temporary. we need to find out any solid solution for this.

EvanAgee commented 6 years ago

@vikash2039 have you thought any more about this?