Scripts: Allow passing local development URL via --hot flag. #67764
Description
What problem does this address?
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.
const defaultConfig = 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.
wp-scripts start --hot mydev.site
Activity