mirror of
git://develop.git.wordpress.org/
synced 2025-04-26 23:22:25 +02:00
Add missing vendors file after r58271.
See #61324. git-svn-id: https://develop.svn.wordpress.org/trunk@58273 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
430c8b091b
commit
5aea85cad3
58
tools/webpack/vendors.js
Normal file
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',
|
||||
},
|
||||
};
|
||||
} );
|
||||
} ),
|
||||
];
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user