feat: Use javascript_tag helper for vite_react_refresh_tag #372
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 methodjavascript_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 asnonce: 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 thereact_preamble_code
method internally inside its<script>...</script>
tags.Screenshots 📷