wordpress/tools/webpack/development.js
Jonathan Desrosiers d13208e291 Build/Test Tools: Update build related dependencies to their latest versions.
This updates the following npm dependencies:
- `autoprefixer` to version `10.4.16`.
- `grunt-contrib-qunit` to version `8.0.1`.
- `postcss` to version `8.4.30`.
- `react-refresh` to version `0.14.0`.
- `sass` to version `1.68.0`.
- `sinon` to version `16.0.0`.
- `uuid` to version `9.0.1`.
- `tslib` to version `2.6.2`.

This change accompanies a similar one in the Gutenberg repository: https://github.com/WordPress/gutenberg/pull/54657.

Props gziolo, desrosj.
Fixes #58863.

git-svn-id: https://develop.svn.wordpress.org/trunk@56647 602fd350-edb4-49c9-b593-d223f7449a82
2023-09-21 13:24:50 +00:00

62 lines
1.6 KiB
JavaScript

/**
* External dependencies
*/
const { join } = require( 'path' );
/**
* WordPress dependencies
*/
const DependencyExtractionWebpackPlugin = require( '@wordpress/dependency-extraction-webpack-plugin' );
const baseDir = join( __dirname, '../../' );
module.exports = function( env = { environment: 'production', 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 sharedConfig = {
mode: 'development',
target: 'browserslist',
output: {
filename: `[name]${ suffix }.js`,
path: join( baseDir, `${ buildTarget }/js/dist/development` ),
},
};
// See https://github.com/pmmmwh/react-refresh-webpack-plugin/blob/main/docs/TROUBLESHOOTING.md#externalising-react.
return [
{
...sharedConfig,
name: 'react-refresh-entry',
entry: {
'react-refresh-entry':
'@pmmmwh/react-refresh-webpack-plugin/client/ReactRefreshEntry.js',
},
plugins: [ new DependencyExtractionWebpackPlugin( {
outputFilename: `../../../assets/script-loader-[name]${ suffix }.php`,
} ) ],
},
{
...sharedConfig,
name: 'react-refresh-runtime',
entry: {
'react-refresh-runtime': {
import: 'react-refresh/runtime',
library: {
name: 'ReactRefreshRuntime',
type: 'window',
},
},
},
plugins: [
new DependencyExtractionWebpackPlugin( {
useDefaults: false,
outputFilename: `../../../assets/script-loader-[name]${ suffix }.php`
} ),
],
},
];
};