Open Velka-DEV opened 3 months ago
PHP dependencies (vendor
directory) are not available during the build of front-end assets in these Dockerfiles. You can do this:
// composer.json
"post-update-cmd": [
...
"@php -r \"copy('vendor/livewire/livewire/dist/livewire.esm', 'resources/js/lib/livewire/livewire.esm');\""
],
// app.js
import { Livewire, Alpine } from './lib/livewire/livewire.esm';
Then, run composer update
and rebuild the image.
We need to expose vendor directory, this is not actually reliable to copy all dependencies.
The ESM module make relative imports like "../alpine/packages/alpinejs/dist/module.cjs.js", we can't copy every single file manually
Maybe this is a good occasion to work on it along with alpine & bun support as it's on the to-do list and would be a rewrite
The docker build will fail if any javascript file import a resource from composer vendor folder (e.g Alpine / Livewire)
import { Livewire, Alpine } from '../../vendor/livewire/livewire/dist/livewire.esm';
This import is from the Livewire documentation: https://livewire.laravel.com/docs/alpine#manually-bundling-alpine-in-your-javascript-build