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

feat: Use javascript_tag helper for vite_react_refresh_tag #372

Conversation

omarowns
Copy link
Contributor

feat: Use javascript_tag helper for vite_react_refresh_tag allowing h…tml_options

Description 📖

This pull request updated the vite_react_refresh_tag method to use the Rails JavaScript helper method javascript_tag in order to support HTML options.

Background 📜

This was happening because of #249. When adding Content Security Policy on a Rails project with something other than unsafe-inline the inline JS for the react refresh script was not being allowed.

The Fix 🔨

By changing the vite_react_refresh_tag to use Rails' javascript_tag we can now add HTML options such as nonce: true.

The code adds the method react_preamble_code which has the script for the React Refresh plugin.

The react_refresh_preamble is left unchanged with the exception of using the react_preamble_code method internally inside its <script>...</script> tags.

Screenshots 📷

@ElMassimo
Copy link
Owner

Looks great, thanks for your contribution Omar!

@ElMassimo ElMassimo merged commit 238c6bd into ElMassimo:main Jun 19, 2023
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