Greg Ziółkowski 4f64273933 Build: Update webpack to v5.x
Update webpack version to latest version https://www.npmjs.com/package/webpack. This aligns closer with how the Gutenberg plugin handles WordPress packages. Related update in Gutenberg from August 2021: https://github.com/WordPress/gutenberg/pull/33818.

Props walbo, desrosj, mukesh27.
Fixes #51750.




git-svn-id: https://develop.svn.wordpress.org/trunk@53135 602fd350-edb4-49c9-b593-d223f7449a82
2022-04-11 12:02:14 +00:00

47 lines
1.5 KiB
JavaScript

/**
* External dependencies
*/
const TerserPlugin = require( 'terser-webpack-plugin' );
/**
* Internal dependencies
*/
const { baseDir } = require( './shared' );
module.exports = function( env = { environment: 'production', watch: false, buildTarget: false } ) {
const entry = {
[ env.buildTarget + 'wp-includes/js/media-audiovideo.js' ]: ['./src/js/_enqueues/wp/media/audiovideo.js'],
[ env.buildTarget + 'wp-includes/js/media-audiovideo.min.js' ]: ['./src/js/_enqueues/wp/media/audiovideo.js'],
[ env.buildTarget + 'wp-includes/js/media-grid.js' ]: ['./src/js/_enqueues/wp/media/grid.js'],
[ env.buildTarget + 'wp-includes/js/media-grid.min.js' ]: ['./src/js/_enqueues/wp/media/grid.js'],
[ env.buildTarget + 'wp-includes/js/media-models.js' ]: ['./src/js/_enqueues/wp/media/models.js'],
[ env.buildTarget + 'wp-includes/js/media-models.min.js' ]: ['./src/js/_enqueues/wp/media/models.js'],
[ env.buildTarget + 'wp-includes/js/media-views.js' ]: ['./src/js/_enqueues/wp/media/views.js'],
[ env.buildTarget + 'wp-includes/js/media-views.min.js' ]: ['./src/js/_enqueues/wp/media/views.js'],
};
const mediaConfig = {
target: 'browserslist',
mode: "production",
cache: true,
entry,
output: {
path: baseDir,
filename: '[name]',
},
optimization: {
minimize: true,
moduleIds: 'deterministic',
minimizer: [
new TerserPlugin( {
include: /\.min\.js$/,
extractComments: false,
} ),
]
},
watch: env.watch,
};
return mediaConfig;
};