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

Added the ability to exclude frontend reload script injection via configuration #1457

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

alallier
Copy link
Member

Added the ability to exclude frontend reload script injection via glob patterns at the server configuration level.

  • Added minimatch as a dependency
    • I opted to do this as it's a npm level dependency and it reduces confusing custom REGEX checking (happy to change)
  • Added new tests to test reload excludeRoutes
    • Added some more testing routes to correctly test the glob excluding in the reload configuration
  • Added default excludeRoutes as empty array

(Closes #1150)

@@ -163,6 +163,35 @@ describe('frontend reload', () => {
assert(res.text.includes('<script src=\'/reloadHttp/reload.js\'></script>'))
})

it('should exclude multiple glob paths for auto inject reload script into rendered html', async () => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wording isn't great...

@alallier alallier requested a review from kethinov August 28, 2024 18:47
@alallier alallier force-pushed the reloadConfig branch 2 times, most recently from f9ea044 to ee51f01 Compare August 28, 2024 18:53
}
})

// check that reload script is injected into response bodies
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy/paste comment is no longer correct


router.route('/HTMLTest/nested').get((req, res) => {
// save the path of the plain HTML page
const htmlPath = path.join(__dirname, '../views/plainHTMLTest.html')
Copy link
Member Author

@alallier alallier Aug 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make these more re-useable later and semantically correct we might want new .html documents.

Let me know and I can update

…b patterns at the server configuration level.

* Added minimatch as a dependency
* Added new tests to test reload excludeRoutes
* Added default excludeRoutes as empty array
@alallier
Copy link
Member Author

We need to hold merge on this for a bit, the test was working before but now it's breaking and there are recursion depth problems that could cause performance issues. Need to handle both of those items before merging

}
```

- `excludeRoutes`: Reload auto script injection happens on all HTML routes by default unless specified in `excludeRoutes`. An array of valid glob patterns is accepted
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `excludeRoutes`: Reload auto script injection happens on all HTML routes by default unless specified in `excludeRoutes`. An array of valid glob patterns is accepted
- `excludeRoutes`: List of routes to exclude from Reload automatically injecting its script onto.
- Default: *[Array]* with no items in it. This means Reload will inject its script on all routes by default.

@kethinov
Copy link
Member

Screenshot 2024-08-28 at 8 49 52 PM

git push force

@@ -372,10 +372,13 @@ Resolves to:
{
"enable": true,
"port": 9856,
"httpsPort": 9857
"httpsPort": 9857,
"excludeRoutes": []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The HTML minifier has a similar param called exceptionRoutes, either this new one, or the old one should be renamed for consistency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Add exception routes configuration to reload module
3 participants