Created
February 2, 2025 11:18
-
-
Save Lovor01/07921a701c7de5e4ab6f471b0e8a865f to your computer and use it in GitHub Desktop.
Wordpress scripts HMR config for one or more blocks
This file contains hidden or 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
| // change webpack default config | |
| const defaultConfig = require( '@wordpress/scripts/config/webpack.config.js' ); | |
| // eslint-disable-next-line import/no-extraneous-dependencies | |
| require( 'dotenv' ).config(); | |
| /* Either define host, cert_location and key_location in .env file | |
| i root directory of the project or encode strings here to use | |
| https and hot reload under https. Alternatively, remove this config file | |
| */ | |
| function changeConfig ( config ) { | |
| config.devServer = { | |
| ...config.devServer, | |
| host: process.env.host, | |
| server: { | |
| type: 'https', | |
| options: { | |
| cert: process.env.cert_location, | |
| key: process.env.key_location, | |
| }, | |
| }, | |
| allowedHosts: [ | |
| process.env.host, | |
| 'localhost', | |
| '127.0.0.1', | |
| ], | |
| }; | |
| // enable this if you are not using weback 4 API-s | |
| // config.experiments = { ...config.experiments, backCompat: false }; | |
| } | |
| if ( process.env.NODE_ENV !== 'production' ) { | |
| if (Array.isArray(defaultConfig)) { | |
| for (const config of defaultConfig ) | |
| changeConfig( config ); | |
| } else { | |
| changeConfig( defaultConfig ); | |
| } | |
| } | |
| module.exports = defaultConfig |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment