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

Suggestion: Do not require -legacy suffix when using vite_legacy_asset #16

Open
mixxorz opened this issue Oct 30, 2021 · 1 comment
Open
Labels
enhancement New feature or request

Comments

@mixxorz
Copy link

mixxorz commented Oct 30, 2021

When using vite_asset, the syntax is:

{% vite_asset 'javascript/main.js' %}

where javascript/main.js is the path to the source file.

However, when using vite_legacy_asset, the syntax requires you to add the -legacy suffix manually.

{% vite_legacy_asset 'javascript/main-legacy.js' %}

I think this might be confusing because javascript/main-legacy.js is not a file that exists. When I use vite_legacy_asset, I expect django-vite to load the legacy version of the file I specify.

{% vite_asset 'javascript/main.js' %} {# Normal version #}
{% vite_legacy_asset 'javascript/main.js' %} {# Legacy version #}

Another thing to consider is that vite_legacy_asset does not crash or give any warning when you don't add the -legacy suffix. Currently, this just loads the non-legacy version of the asset with <script nomodule>.

{% vite_legacy_asset 'javascript/main.js' %}

I think many people will be caught out by this. I suggest that django-vite not require the -legacy suffix when using vite_asset_legacy.

Keen to hear your thoughts on this.

@MrBin99
Copy link
Owner

MrBin99 commented Nov 17, 2021

I agree with you but if some day the Vite Legacy plugin change its behaviour and put another suffix. People using Django Vite will
be stuck because -legacy is hardcoded.

You're right that vite_legacy_asset do nothing more than vite_asset. But I prefer a library where people understand what they are doing, how the library works and a library where people have a maximum of control on what the library do for them.

What do you think ?

@MrBin99 MrBin99 added the enhancement New feature or request label Mar 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants