You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Scripts: Allow passing local development URL via --hot flag. #67764
When using Fast refresh via the --hot flag, the webpack configuration setsdevServer.allowedHosts to auto. This allows a small set of URLs to be used( 'localhost', 'host' , and client.webSocketURL.hostname). If the domain being used doesn't match one of those, there are no errors and Fast refresh doesn't work.
Currently, the only way to modify this setting is to create a custom webpack.config.js file and add the code below. Adding an entire new config to enable this feature is a large, and IMO, unnecessary barrier to usage.
// Import the original config from the @wordpress/scripts package.constdefaultConfig=require('@wordpress/scripts/config/webpack.config');// Add any a new entry point by extending the webpack config.module.exports={
...defaultConfig,devServer: {
...defaultConfig.devServer,allowedHosts: 'mysite.dev',},};
What is your proposed solution?
I propose that we add the ability to pass an optional value to the existing --hot flag that would be used as the value for devServer.allowedHosts in the config. If the value is not set or was an invalid URL, the config would continue to use auto as the default.
There is also the question what is your configuration as I assumed that both the WordPress site and the dev server would be served from the same custom domain on different ports. The more details you provide the more I can help to sort out the changes necessary to the default configuration.
By the way, we could also tweak the default configuration so the port for the dev server is only set when the custom host is not provided. Although again it all depends what is the host for the dev server vs the host for WordPress.
Closing as already possible: as explained above, wp-scripts start passes through webpack-dev-server CLI flags, so --allowed-hosts / --host handle custom local domains today without code changes
Activity
gziolo commentedon Dec 11, 2024
It’s already possible through CLI as explained in https://webpack.js.org/configuration/dev-server/#devserverallowedhosts, example:
I see the value is set to
autowhich will accept value set ashostwith https://webpack.js.org/configuration/dev-server/#devserverhost, example:Noting that
wp-scripts startuseswebpack servebehind the scenes.ryanwelcher commentedon Dec 11, 2024
Ah interesting. I'll see if I can get this working without needed to make code changes.
gziolo commentedon Dec 11, 2024
There is also the question what is your configuration as I assumed that both the WordPress site and the dev server would be served from the same custom domain on different ports. The more details you provide the more I can help to sort out the changes necessary to the default configuration.
gziolo commentedon Dec 11, 2024
By the way, we could also tweak the default configuration so the
portfor the dev server is only set when the custom host is not provided. Although again it all depends what is the host for the dev server vs the host for WordPress.Docs: Clarify wp-scripts start --hot (Fast Refresh) setup
youknowriad commentedon Aug 5, 2026
Closing as already possible: as explained above, wp-scripts start passes through webpack-dev-server CLI flags, so --allowed-hosts / --host handle custom local domains today without code changes