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

Additional attributes on <link rel="stylesheet"> tag #140

Closed
KyeRussell opened this issue Jul 5, 2024 · 2 comments · Fixed by #142
Closed

Additional attributes on <link rel="stylesheet"> tag #140

KyeRussell opened this issue Jul 5, 2024 · 2 comments · Fixed by #142

Comments

@KyeRussell
Copy link

I'm very new to this project so please correct me if I'm wrong, but it seems to me that there's no way for me to ask {% vite_asset %} to put, say, media="print" on the <link rel="stylesheet" ...> it generates for a given asset.

I've suboptimally worked around this using {% vite_asset_url %} for the time being.

I'll probably take a look at submitting a PR for this a bit later, however it looks quite difficult to accomplish whilst maintaining {% vite_asset %}'s current API.

@KyeRussell KyeRussell changed the title Additional properties on CSS inclusion tag Additional properties on <link rel="stylesheet"> tag Jul 5, 2024
@KyeRussell KyeRussell changed the title Additional properties on <link rel="stylesheet"> tag Additional attributes on <link rel="stylesheet"> tag Jul 5, 2024
@Niicck
Copy link
Collaborator

Niicck commented Jul 6, 2024

Yep, you're right. Currently we can only assign attributes to the js script tag, not the css stylesheet link. You're also correct that adding this feature would require an update to the API.

I think to get this to work, we'd want to do something like django-webpack-loader where you can split out the bundles of 'css' and 'js' and assign attributes to each one distinctly: https://github.com/django-webpack/django-webpack-loader?tab=readme-ov-file#rendering-by-file-extension

Take a look at the TagGenerator to get an idea of how attribute assignment is currently done. You're welcome to submit a PR.

@KyeRussell
Copy link
Author

Heh. I'm actually migrating over from Webpack and django-webpack-loader! Cheers 👍

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 a pull request may close this issue.

2 participants