Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node assets build should occur after composer install #68

Open
Velka-DEV opened this issue Apr 3, 2024 · 3 comments
Open

Node assets build should occur after composer install #68

Velka-DEV opened this issue Apr 3, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@Velka-DEV
Copy link

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

@smortexa
Copy link
Member

smortexa commented Apr 4, 2024

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.

@Velka-DEV
Copy link
Author

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

@smortexa smortexa added the enhancement New feature or request label Apr 5, 2024
@Velka-DEV
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants