Skip to content

[9.x] Adding option for custom manifest filename on Vite Facade#45007

Merged
taylorotwell merged 2 commits into
laravel:9.xfrom
ngstwr:9.x
Nov 21, 2022
Merged

[9.x] Adding option for custom manifest filename on Vite Facade#45007
taylorotwell merged 2 commits into
laravel:9.xfrom
ngstwr:9.x

Conversation

@ngstwr

@ngstwr ngstwr commented Nov 18, 2022

Copy link
Copy Markdown
Contributor

Option added to pass the name of the manifest file to be used while using the Vite Facade.

Before:
Vite::asset(['resources/sass/app.scss'], 'dist')

Now:
Vite::asset(['resources/sass/app.scss'], 'dist', 'app-manifest.json')

@ngstwr

ngstwr commented Nov 18, 2022

Copy link
Copy Markdown
Contributor Author

In response to this issue: #45002

@taylorotwell taylorotwell marked this pull request as draft November 18, 2022 15:12
@timacdonald timacdonald changed the title Adding option for custom manifest filename on Vite Facade [9.x] Adding option for custom manifest filename on Vite Facade Nov 20, 2022
@timacdonald

timacdonald commented Nov 21, 2022

Copy link
Copy Markdown
Member

Hey @ngstwr,

Thanks for the PR. I've tweaked the implementation slightly. In a global service provider, route based middleware, or inline in a view, you may now specify the manifest file with the following API...

Service provider / middleware example...

use Illuminate\Support\Facades\Vite;

Vite::useManifestFilename('custom-manifest.json');
{{-- Uses the custom manifest filename --}}

@vite(['resources/js/app.js'])

Inline example...

{{ Vite::useManifestFilename('custom-manifest.json')->withEntryPoints(['resources/js/app.js']) }}

Documentation PR: laravel/docs#8352

@timacdonald timacdonald marked this pull request as ready for review November 21, 2022 00:16
@ngstwr

ngstwr commented Nov 21, 2022

Copy link
Copy Markdown
Contributor Author

@timacdonald This is indeed a better way!

Somewhat related to this PR:

Shouldn't we do this with the 'buildDirectory' parameter also?

If we can use the new API (useManifestFilename) via a global service provider or route-based middleware, it doesn't make sense to pass the custom build directory path as a parameter with every @Vite() call.

Let me know what you think!

@timacdonald

Copy link
Copy Markdown
Member

@ngstwr that is already available with Vite::useBuildDirectory($path).

See: https://laravel.com/docs/9.x/vite#advanced-customization

@ngstwr

ngstwr commented Nov 21, 2022

Copy link
Copy Markdown
Contributor Author

Oh, thanks, somehow I missed that section on the documentation!

Will wait for this PR to be merged!

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