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: avoid removing double extension for non-preprocessor assets #301

Merged
merged 5 commits into from
Nov 13, 2022

Conversation

ElMassimo
Copy link
Owner

@ElMassimo ElMassimo commented Nov 11, 2022

Description 📖

This pull request makes some changes to ensure CSS filenames such as jquery.tree.css are not converted to jquery.tree in the ViteRuby::DevServerProxy.

Background 📜

Historically, stylesheet_link_tag in Rails did not support passing extname to asset_path, causing it to always append .css to any provided filenames.

This is problematic in Vite, because the dev server can serve file.scss.

For that reason, the DevServerProxy needed to convert that file.scss.css to file.css.

Since it's very uncommon for CSS files to have two extensions, the naive approach of removing the extra .css hasn't been a problem in practice, until #300.

The Fix 🔨

Restricting this patch to files with a known CSS preprocessor extension. The regex is more verbose, but should cause less problems.

In addition, support for extname was added in Rails 7, so in the future it will be possible to stop using this patch in the proxy.

@ElMassimo ElMassimo merged commit 2024f62 into main Nov 13, 2022
@ElMassimo ElMassimo deleted the fix/proxy-css branch November 13, 2022 19:59
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.

1 participant