-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathwp-scripts.config.js
More file actions
72 lines (69 loc) · 1.43 KB
/
wp-scripts.config.js
File metadata and controls
72 lines (69 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/**
* Custom WP Scripts configuration.
*
* - Enables HOT reloading for development.
*
*/
const defaultConfig = require('@wordpress/scripts/config/webpack.config');
const path = require('path');
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/**',
'**/assets/build/**',
'**/dist/**',
'**/*.hot-update.*',
],
aggregateTimeout: 300,
},
module: {
...defaultConfig.module,
rules: [
...defaultConfig.module.rules,
{
test: /tailwind.*\.css$/,
sideEffects: false,
use: [
{
loader: 'style-loader',
options: {
injectType: 'singletonStyleTag',
},
},
'css-loader',
],
},
],
},
};