-
Notifications
You must be signed in to change notification settings - Fork 0
Replace browser-sync with django-browser-reload for auto-reload functionality #2
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
Conversation
…ionality Co-authored-by: MauGx3 <[email protected]>
…fully Co-authored-by: MauGx3 <[email protected]>
MauGx3
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| content = json.loads(package_json.read_text()) | ||
| for package_name in remove_dev_deps: | ||
| content["devDependencies"].pop(package_name) | ||
| content["devDependencies"].pop(package_name, None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot explain the reasoning behind this change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change on line 131 adds graceful error handling when removing browser-sync from package.json. The original code used .pop(package_name) which would raise a KeyError if the package doesn't exist. Since browser-sync was removed from the default dependencies, this change ensures the post-generation hook doesn't fail when trying to remove a package that may not be present in all frontend pipeline configurations. Using .pop(package_name, None) safely removes the package if it exists or returns None if it doesn't, preventing build failures during project generation.
Fixed in commit a247d22.
The gulpfile.mjs changes represent the core transformation of this PR - replacing JavaScript-based browser-sync with Python-based django-browser-reload. Key changes made:
This simplifies the build pipeline significantly while providing better Django integration. Instead of relying on a JavaScript proxy server, django-browser-reload uses Django's native mechanisms to detect file changes and trigger browser reloads directly. Implemented in commit d6f7d1f. |
This PR implements the changes requested in issue cookiecutter#3745 to replace the JavaScript-based browser-sync with the Python-based
django-browser-reloadfor auto-reload functionality during local development.Problem
The existing implementation used browser-sync for live reloading, which had several issues:
Solution
This PR replaces browser-sync with
django-browser-reload, which provides:Changes Made
Dependencies & Configuration
browser-syncdependency frompackage.jsondjango-browser-reload==1.15.0torequirements/local.txtdjango_browser_reloadtoINSTALLED_APPSin local settingsdjango_browser_reload.middleware.BrowserReloadMiddlewaretoMIDDLEWAREin local settings__reload__/) to URL configurationBuild Pipeline
gulpfile.mjsinitBrowserSync()function and related proxy configurationDocumentation
developing-locally.rstto reference django-browser-reload instead of browser-syncCompatibility
Benefits
Testing
All existing tests continue to pass, including:
The implementation maintains backward compatibility while providing a more robust and Django-native auto-reload solution.
Fixes cookiecutter#3745
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.