Skip to content

Conversation

axlon
Copy link
Contributor

@axlon axlon commented Jul 25, 2022

When using the new Vite plugin to compile assets its currently not possible to define how style and script tags are generated, this PR aims to change that.

This will allow developers to change the tags for their assets to their specific needs (my own use-case being a CSP nonce).

Usage would be:

use Illuminate\Foundation\Vite;

Vite::makeScriptTagUsing(function (string $url) {
    return sprintf('<script type="module" src="%s" defer></script>', $url);
});

Vite::makeStylesheetTagUsing(function (string $url) {
    return sprintf('<link rel="stylesheet" href="%s" crossorigin />', $url);
});

@taylorotwell taylorotwell marked this pull request as draft July 25, 2022 13:23
@taylorotwell taylorotwell requested a review from jessarcher July 25, 2022 13:23
@timacdonald
Copy link
Member

timacdonald commented Jul 27, 2022

Hey @axlon, thank you for the PR.

We dig idea, however as it stands the PR will only allow you to add generic attributes - but we want to see if we can come up with a solution that will allow us to handle CSP, SRI, and generic attributes.

We are actively working on a holistic solution to all of these, as they all share a similar problem space, and will send up an alternative PR shortly and get your thoughts and feedback on it.

See: #43442

@axlon
Copy link
Contributor Author

axlon commented Jul 27, 2022

Sounds good @timacdonald !

@axlon
Copy link
Contributor Author

axlon commented Jul 28, 2022

Closing this in favor of #43442

@axlon axlon closed this Jul 28, 2022
@axlon axlon deleted the vite-tag-generation branch July 28, 2022 07:26
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.

2 participants