wordpress-develop/tools/webpack/modules.js
Riad Benguella cf8b74de16 Editor: Update the WordPress packages to the Gutenberg 16.7 RC2 version.
This patch, somewhat small brings a lot to WordPress. 
This includes features like:

 - DataViews.
 - Customization tools like box shadow, background size and repeat.
 - UI improvements in the site editor. 
 - Preferences sharing between the post and site editors.
 - Unified panels and editors between post and site editors.
 - Improved template mode in the post editor.
 - Iterations to multiple interactive blocks.
 - Preparing the blocks and UI for pattern overrides.
 - and a lot more.

Props luisherranz, gziolo, isabel_brison, costdev, jonsurrell, peterwilsoncc, get_dave, antonvlasenko, desrosj.
See #60315.

git-svn-id: https://develop.svn.wordpress.org/trunk@57377 602fd350-edb4-49c9-b593-d223f7449a82
2024-01-29 21:04:18 +00:00

94 lines
1.9 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 },
},
module: {
rules: [
{
test: /\.(j|t)sx?$/,
use: [
{
loader: require.resolve( 'babel-loader' ),
options: {
cacheDirectory:
process.env.BABEL_CACHE_DIRECTORY || true,
babelrc: false,
configFile: false,
presets: [
[
'@babel/preset-react',
{
runtime: 'automatic',
importSource: 'preact',
},
],
],
},
},
],
},
],
},
plugins: [
...baseConfig.plugins,
new DependencyExtractionPlugin( {
injectPolyfill: false,
useDefaults: false,
} ),
],
};
return config;
};