I started a fresh WP multisite project that has two themes - both built with Sage. The website project uses Bedrock and the “Multisite URL fixer” mu-plugin has been installed.
I have two sites in my local environment:
- mysite dot local
- anothersite.mysite dot local
The primary site works fine - no issues there. On the non-primary site, that is located in subdomain, there is an issue loading JavaScript assets with:
@vite(['resources/css/app.css', 'resources/js/app.js'])
CSS is loading fine, but JS-file is being loaded from the primary website’s domain when building assets with Vite’s build. When Hot module loading (dev mode) is running, JS is being loaded as should be.
I found out that the environment variable WP_HOME in project’s root folder is used to form the host/domain for JS assets url. If I change it to be my subdomain, JS is loading properly. But naturally this isn’t the solution, since the primary site will stop working.
In Sage theme and Laravel, how can I tell the app to load JS files using the subdomain instead of the primary domain?