arnoson / kirby-vite-multi-page-kit

A multi-page Kirby CMS + Vite starter kit
MIT License
37 stars 6 forks source link

Some assets not loading #6

Closed cgundermann closed 2 years ago

cgundermann commented 2 years ago

Hey,

thanks a lot for sharing Your plugin. I'm having trouble to load the font after executing npm run build.

I did the following steps in the exact same order, afer cloning the rep:

composer install
npm install
npm run build

when visiting the site at http://localhost/kirby-vite-multi-page-kit/public/, all assets get loaded except the font. It's pointing to http://localhost/dist/assets/Compagnon-Bold.60bba4d6.woff2 whereas all other assets are pointing to http://localhost/kirby-vite-multi-page-kit/public/dist/assets/[name].[hash].js

I appreciate Your help, Thank You!

Cris

arnoson commented 2 years ago

Glad you like the plugin :)

When you wan't to preview the build locally, you have to run npm run server and visit localhost:8888. In the package.json you can see that the php dev server uses the public folder and the server.php file to get kirby's routing right (because htaccess won't work in php's dev server). If you don't want to use the php dev server but rather something like laravel valet, you have to point the server to the public folder and make sure htaccess is working.

Runnig the website in a subdirectory like http://localhost/kirby-vite-multi-page-kit/public/ won't work unless you change the public base path in vite.config.js. Hope this helps!

cgundermann commented 2 years ago

Thank You, I got it working =) I still had to link the fonts in my project like this:

  src: url('dist/../../../assets/fonts/cairo/cairo-v14-latin-regular.woff2') format('woff2'); 

This pattern it didn't work – the hashed fonts didn't get copied to the dist folder, really don't know why....

  src: url('assets/fonts/cairo/cairo-v14-latin-regular.woff2') format('woff2');

I might have to check again, what I was doing wrong, but after two days of trial and error I'm done for now....