mirror of
git://develop.git.wordpress.org/
synced 2025-02-23 16:15:31 +01:00
It brings with a set of iterations and follow-ups to the initial package update. It also fixes a regression that happened for interactive blocks. Props gziolo, luisherranz, cbravobernal. See #60315. git-svn-id: https://develop.svn.wordpress.org/trunk@57499 602fd350-edb4-49c9-b593-d223f7449a82
73 lines
1.6 KiB
JavaScript
73 lines
1.6 KiB
JavaScript
/**
|
|
* WordPress dependencies
|
|
*/
|
|
const DependencyExtractionPlugin = require( '@wordpress/dependency-extraction-webpack-plugin' );
|
|
|
|
/**
|
|
* Internal dependencies
|
|
*/
|
|
const {
|
|
baseDir,
|
|
getBaseConfig,
|
|
normalizeJoin,
|
|
MODULES,
|
|
WORDPRESS_NAMESPACE,
|
|
} = require( './shared' );
|
|
|
|
module.exports = function (
|
|
env = { environment: 'production', watch: false, buildTarget: false }
|
|
) {
|
|
const mode = env.environment;
|
|
const suffix = mode === 'production' ? '.min' : '';
|
|
let buildTarget = env.buildTarget
|
|
? env.buildTarget
|
|
: mode === 'production'
|
|
? 'build'
|
|
: 'src';
|
|
buildTarget = buildTarget + '/wp-includes';
|
|
|
|
const baseConfig = getBaseConfig( env );
|
|
const config = {
|
|
...baseConfig,
|
|
entry: MODULES.map( ( packageName ) =>
|
|
packageName.replace( WORDPRESS_NAMESPACE, '' )
|
|
).reduce( ( memo, packageName ) => {
|
|
memo[ packageName ] = {
|
|
import: normalizeJoin(
|
|
baseDir,
|
|
`node_modules/@wordpress/${ packageName }`
|
|
),
|
|
};
|
|
|
|
return memo;
|
|
}, {} ),
|
|
experiments: {
|
|
outputModule: true,
|
|
},
|
|
output: {
|
|
devtoolNamespace: 'wp',
|
|
filename: `[name]${ suffix }.js`,
|
|
path: normalizeJoin( baseDir, `${ buildTarget }/js/dist` ),
|
|
library: {
|
|
type: 'module',
|
|
},
|
|
environment: { module: true },
|
|
},
|
|
externalsType: 'module',
|
|
externals: {
|
|
'@wordpress/interactivity': '@wordpress/interactivity',
|
|
'@wordpress/interactivity-router':
|
|
'import @wordpress/interactivity-router',
|
|
},
|
|
plugins: [
|
|
...baseConfig.plugins,
|
|
new DependencyExtractionPlugin( {
|
|
injectPolyfill: false,
|
|
useDefaults: false,
|
|
} ),
|
|
],
|
|
};
|
|
|
|
return config;
|
|
};
|