Tangible Bytes

A Web Developer’s Blog

Laravel Vite Wont Serve Build Files

This is a silly one.

I wanted to run Laravel in dev mode but using the compiled js and scss from npm run build via vitejs.

This usually works

but for some reason Laravel was trying to serve js/css from http://localhost:5173/@vite/client

a service I usually run - but I wanted to test the build stuff.

The solution is really simple but not well documented.

Read more ...

Vitest Partial Mock InertiaJs

I have a Laravel project using vite InertiaJS and React

A unit test calling the Head module from @inertiajs/react

Was triggering this error

Cannot read properties of undefined (reading 'createProvider')

For this test I don’t really care about the Head module - but didn’t want to try and mock the whole of inertia-react

Read more ...

Multiple Authentication in Laravel

You may not need this, if you can manage multiple types of user via roles and permissions it will be much the simpler route to follow.

In my case I wanted user with different: properties, relationships, routes, password rules, timeouts, and more.

It was worth the pain of setting up two authenticatable models.

Laravel is very flexible and well documented, but the further you stray from what most people do - the less obvious it is and a few of these steps took me a while to figure out.

Read more ...

Windows 11 WSL2 and Docker Desktop

I’m a long time Linux user, and a big fan of Docker, Kubernetes, VMs, and containers.

While I love developing on Linux - I do sometimes find it frustrating that I don’t have the same level of access to the Microsoft suite on Linux.

A while ago I had to use a Windows laptop for a few days and tried out using WSL - so most of the time I’m in Linux - I didn’t entirely hate it so when it was time for an upgrade I decided to try the Windows route this time.

I’ve had my new machine for a little over a week now.

Read more ...