Skip to content

feat: Use javascript_tag helper for vite_react_refresh_tag#372

Merged
ElMassimo merged 1 commit intoElMassimo:mainfrom
omarowns:feat/update-vite_react_refresh_tag-with-javascript_tag
Jun 19, 2023
Merged

feat: Use javascript_tag helper for vite_react_refresh_tag#372
ElMassimo merged 1 commit intoElMassimo:mainfrom
omarowns:feat/update-vite_react_refresh_tag-with-javascript_tag

Conversation

@omarowns
Copy link
Copy Markdown
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
Copy Markdown
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