Created
March 26, 2023 15:24
-
-
Save bahiirwa/558cb07b175116bf2ff33c39dcd35eaf to your computer and use it in GitHub Desktop.
Multiple entry points for webpack.config.js using @wordpress/scripts
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
// Set from https://www.npmjs.com/package/@wordpress/scripts | |
// Add package.json with the @wordpress/scripts dependency. | |
// Add a root file called webpack.config.js | |
// Import the original config from the @wordpress/scripts package. | |
const defaultConfig = require( '@wordpress/scripts/config/webpack.config' ); | |
// Import the helper to find and generate the entry points in the src directory | |
const { getWebpackEntryPoints } = require( '@wordpress/scripts/utils/config' ); | |
// Add any a new entry point by extending the webpack config. | |
module.exports = { | |
...defaultConfig, | |
entry: { | |
...getWebpackEntryPoints(), | |
variations: './variations/index.js', // to variations file in theme. | |
'stream-meta-panel': './stream-meta-panel/index.js', // Custom directory having JS to compile | |
}, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment