-
Notifications
You must be signed in to change notification settings - Fork 175
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
[1.x] Manually inline Livewire assets #266
Conversation
@@ -50,7 +47,7 @@ | |||
</main> | |||
</div> | |||
|
|||
@livewireScripts | |||
@stack('scripts') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The @stack('scripts')
was a remnant from our previous iterations. We no longer use this.
@livewireStyles | ||
|
||
{!! Laravel\Pulse\Facades\Pulse::js() !!} | ||
@livewireScriptConfig |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When Livewire detects the @livewireScriptConfig directive, it will refrain from injecting the Livewire and Alpine scripts. If you are using the @livewireScripts directive to manually load Livewire, be sure to remove it. Make sure to add the @livewireStyles directive if it is not already present.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I initially thought we should remove our lock file, but we need it for our build step that commits the built assets.
I've updated the dependencies while I was looking at all this.
We've had numerous reports of issues loading Livewire's dynamic
/livewire/livewire.js
route on deployed environments.fixes #85, #131, #145, #164, #201, #263
This is a known issue that Livewire documents.
We have been telling people to update their NGINX configuration, however it would be nice if Pulse "just worked".
Livewire's recommend solution is to build their scripts into your
app.js
via a build tool, such as Vite. We cannot do this as we might build against Livewire3.0.1
while the end user may install Livewire3.3.0
that requires different built assets.Instead we can inline Livewire's assets via
file_get_contents
. We will always output the correct Livewire assets for the currently installed Livewire version.Having the assets cached at a URL is not really any benefit to Pulse. It makes sense for a full-blown Livewire application, but for a single page dashboard like Pulse it is fine to inline the assets and download them on every dashboard visit as you would usually be viewing the same page for some time and only occasionally doing full page reloads. We also do not need to consider SEO performance.