Add missing vendors file after r58271.

See .



git-svn-id: https://develop.svn.wordpress.org/trunk@58273 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ella 2024-05-31 18:08:56 +00:00
parent 430c8b091b
commit 5aea85cad3

58
tools/webpack/vendors.js Normal file

@ -0,0 +1,58 @@
/**
* External dependencies
*/
const { join } = require( 'path' );
const importedVendors = {
react: { import: 'react', global: 'React' },
'react-dom': { import: 'react-dom', global: 'ReactDOM' },
'react-jsx-runtime': {
import: 'react/jsx-runtime',
global: 'ReactJSXRuntime',
},
};
module.exports = function (
env = { environment: 'production', watch: false, buildTarget: false }
) {
const mode = env.environment;
let buildTarget = env.buildTarget
? env.buildTarget
: mode === 'production'
? 'build'
: 'src';
buildTarget = buildTarget + '/wp-includes/js/dist/vendor/';
return [
...Object.entries( importedVendors ).flatMap( ( [ name, config ] ) => {
return [ 'production', 'development' ].map( ( currentMode ) => {
return {
mode: currentMode,
target: 'browserslist',
output: {
filename:
currentMode === 'development'
? `[name].js`
: `[name].min.js`,
path: join( __dirname, '..', '..', buildTarget ),
},
entry: {
[ name ]: {
import: config.import,
library: {
name: config.global,
type: 'window',
},
},
},
externals:
name === 'react'
? {}
: {
react: 'React',
},
};
} );
} ),
];
};