Skip to content

Commit c74b9f6

Browse files
committed
chore: enable hot-reloading on dashboard JS watch
1 parent ab3707d commit c74b9f6

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
},
1919
"scripts": {
2020
"build:dashboard": "wp-scripts build assets/src/dashboard/index.js --output-path=assets/build/dashboard",
21-
"dev:dashboard": "wp-scripts start assets/src/dashboard/index.js --output-path=assets/build/dashboard",
21+
"dev:dashboard": "wp-scripts start assets/src/dashboard/index.js --output-path=assets/build/dashboard --hot --allowed-hosts all",
2222
"build-dev:dashboard": "NODE_ENV=development wp-scripts build assets/src/dashboard/index.js --output-path=assets/build/dashboard",
2323
"build:media": "wp-scripts build assets/src/media/*.js --output-path=assets/build/media",
2424
"dev:media": "wp-scripts start assets/src/media/*.js --output-path=assets/build/media",

wp-scripts.config.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// wp-scripts.config.js
2+
const defaultConfig = require( '@wordpress/scripts/config/webpack.config' );
3+
4+
module.exports = {
5+
...defaultConfig,
6+
devServer: {
7+
...defaultConfig.devServer,
8+
allowedHosts: [ 'all', '.test' ],
9+
headers: {
10+
'Access-Control-Allow-Origin': '*',
11+
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',
12+
'Access-Control-Allow-Headers': 'X-Requested-With, content-type, Authorization'
13+
},
14+
host: '0.0.0.0',
15+
port: 8887,
16+
hot: true,
17+
https: true,
18+
client: {
19+
webSocketURL: 'wss://localhost:8887/ws',
20+
overlay: true
21+
},
22+
setupMiddlewares: ( middlewares, devServer ) => {
23+
if ( ! devServer ) {
24+
throw new Error( 'webpack-dev-server is not defined' );
25+
}
26+
27+
// Add CORS headers to all responses
28+
devServer.app.use( ( req, res, next ) => {
29+
res.header( 'Access-Control-Allow-Origin', '*' );
30+
next();
31+
});
32+
33+
return middlewares;
34+
}
35+
},
36+
watchOptions: {
37+
ignored: /node_modules/,
38+
aggregateTimeout: 300
39+
}
40+
};

0 commit comments

Comments
 (0)