Skip to content

[9.x] Add manifestHash function to Illuminate\Foundation\Vite - #44136

Merged
taylorotwell merged 3 commits into
laravel:9.xfrom
innocenzi:feat/vite-hash
Sep 15, 2022
Merged

[9.x] Add manifestHash function to Illuminate\Foundation\Vite#44136
taylorotwell merged 3 commits into
laravel:9.xfrom
innocenzi:feat/vite-hash

Conversation

@innocenzi

Copy link
Copy Markdown
Contributor

This PR adds a hash method to Illuminate\Foundation\Vite that returns a unique hash if the manifest exists. This is useful to invalidate assets, for instance using Inertia:

<?php

// ...

class HandleInertiaRequests extends Middleware
{

    // ...

    public function version(Request $request): ?string
    {
        return Vite::hash();
    }
}

@innocenzi innocenzi changed the title feat: add hash function to Vite [9.x] Add hash function to Illuminate\Foundation\Vite Sep 14, 2022

@timacdonald timacdonald left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Useful for any long-lived front-end.

Thought: Wonder if Vite::manifestHash() might indicate better what it is doing?

@innocenzi

Copy link
Copy Markdown
Contributor Author

@timacdonald Fine by me, I updated the PR 👍

@innocenzi innocenzi changed the title [9.x] Add hash function to Illuminate\Foundation\Vite [9.x] Add manifestHash function to Illuminate\Foundation\Vite Sep 15, 2022
@taylorotwell
taylorotwell merged commit 74cad57 into laravel:9.x Sep 15, 2022
@innocenzi
innocenzi deleted the feat/vite-hash branch September 15, 2022 19:37
@timacdonald

Copy link
Copy Markdown
Member

Thank you Enzo!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants