Skip to content

Instantly share code, notes, and snippets.

@bahiirwa
Created March 26, 2023 15:24
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save bahiirwa/558cb07b175116bf2ff33c39dcd35eaf to your computer and use it in GitHub Desktop.
Save bahiirwa/558cb07b175116bf2ff33c39dcd35eaf to your computer and use it in GitHub Desktop.
Multiple entry points for webpack.config.js using @wordpress/scripts
// 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