-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: enable hot-reloading on dashboard JS watch
- Loading branch information
Showing
2 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// wp-scripts.config.js | ||
const defaultConfig = require( '@wordpress/scripts/config/webpack.config' ); | ||
|
||
module.exports = { | ||
...defaultConfig, | ||
devServer: { | ||
...defaultConfig.devServer, | ||
allowedHosts: [ 'all', '.test' ], | ||
headers: { | ||
'Access-Control-Allow-Origin': '*', | ||
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS', | ||
'Access-Control-Allow-Headers': 'X-Requested-With, content-type, Authorization' | ||
}, | ||
host: '0.0.0.0', | ||
port: 8887, | ||
hot: true, | ||
https: true, | ||
client: { | ||
webSocketURL: 'wss://localhost:8887/ws', | ||
overlay: true | ||
}, | ||
setupMiddlewares: ( middlewares, devServer ) => { | ||
if ( ! devServer ) { | ||
throw new Error( 'webpack-dev-server is not defined' ); | ||
} | ||
|
||
// Add CORS headers to all responses | ||
devServer.app.use( ( req, res, next ) => { | ||
res.header( 'Access-Control-Allow-Origin', '*' ); | ||
next(); | ||
}); | ||
|
||
return middlewares; | ||
} | ||
}, | ||
watchOptions: { | ||
ignored: /node_modules/, | ||
aggregateTimeout: 300 | ||
} | ||
}; |