feat: hot reload#672
Conversation
There was a problem hiding this comment.
Pull request overview
Adds BrowserSync-based live reload (CSS injection + full-page reload) to the theme’s development workflow, integrating it into the existing webpack-based asset pipeline and conditionally loading the BrowserSync client in local/dev WordPress environments.
Changes:
- Add
browser-sync+browser-sync-webpack-pluginand wire BrowserSync into the webpack “scripts” config. - Add an
npm run devscript to run webpack in watch mode with the multi-config setup. - Conditionally enqueue the BrowserSync client script in PHP for
local/developmentenvironments.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| webpack.config.js | Adds BrowserSyncWebpackPlugin to enable reload/inject behavior during webpack watch builds. |
| package.json | Adds BrowserSync deps and a new dev watch script for the enhanced dev loop. |
| package-lock.json | Locks newly added BrowserSync-related dependencies. |
| inc/classes/class-assets.php | Enqueues the BrowserSync client on local/development to enable snippet-mode reloads. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
bhavz-10
left a comment
There was a problem hiding this comment.
- Acceptance gap: docs/hmr.md is missing.
- Acceptance gap: npm run build does not exist.
The Base branch is main. I believe it should be theme-elementary-v2. That will need some work to change.
e6f6e9a to
a41a661
Compare
|
@bhavz-10 implemented your feedback. |
Description
Adds live reload and CSS hot-reloading to the dev workflow via BrowserSync. Running
npm run devnow watches for file changes. CSS updates inject in-place without a full reload; PHP, HTML, and JS changes trigger a full page reload.Technical Details
Implementation: BrowserSync snippet mode
instances on the same port).
https://localhost:3000. Requires define('WP_ENVIRONMENT_TYPE', 'local') in wp-config.php.
Known limitation: Manually adding SSL certs
To make this work without opening the site on a different port(3000, in proxy mode), SSL cert paths will have to be added in .env.local (see .env.local.example)
Checklist
Fixes/Covers issue
Fixes #643