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

Fix duplicate stylesheet registration when a CSS is imported by more than one entrypoints #90

Open
kucrut opened this issue Jun 13, 2024 · 3 comments

Comments

@kucrut
Copy link
Owner

kucrut commented Jun 13, 2024

See #86 (comment)

@netlas
Copy link
Contributor

netlas commented Jun 13, 2024

My solution #86 relied on wordpress wp_enqueue_style removing duplicate registered handles once that is called. Was that not working properly? Or would you rather have it removed from the internal asset array?

@kucrut
Copy link
Owner Author

kucrut commented Jun 14, 2024

From your example manifest file, I registered resources/js/admin.ts and resources/js/admin_menu.ts as two different assets with Vite\enqueue_asset(). Since they have different handles, the assets/Menu-c4e73a0f.css they load have different handles as well, hence the duplication.

@netlas
Copy link
Contributor

netlas commented Jun 14, 2024

I see what you mean now. A possible solution would be to remove the handle option as a prefix.
replace row 347

$style_handle = "{$options['handle']}-{$slug}";

with

$style_handle = $slug;

Vite is making filenames unique, so an extra prefix in the handles are not necessary for any other reason than semantics.

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

No branches or pull requests

2 participants