File size: 1,564 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
/**
*WARNING: No ES6 modules here. Not transpiled! ****
*/
const path = require( 'path' );
const getBaseWebpackConfig = require( '@automattic/calypso-build/webpack.config.js' );
const DependencyExtractionWebpackPlugin = require( '@wordpress/dependency-extraction-webpack-plugin' );
const webpack = require( 'webpack' );
const GenerateChunksMapPlugin = require( '../../build-tools/webpack/generate-chunks-map-plugin' );
function getWebpackConfig( env, argv ) {
const webpackConfig = getBaseWebpackConfig( { ...env, WP: true }, argv );
return {
...webpackConfig,
entry: {
build: path.join( __dirname, 'src', 'index' ),
},
output: {
...webpackConfig.output,
filename: '[name].min.js',
},
plugins: [
...webpackConfig.plugins.filter(
( plugin ) => plugin.constructor.name !== 'DependencyExtractionWebpackPlugin'
),
new GenerateChunksMapPlugin( {
output: path.resolve( __dirname, 'dist/chunks-map.json' ),
} ),
new webpack.DefinePlugin( {
__i18n_text_domain__: JSON.stringify( 'command-palette' ),
} ),
new DependencyExtractionWebpackPlugin( {
injectPolyfill: true,
outputFilename: '[name].asset.php',
requestToExternal( request ) {
// The extraction logic will only extract a dependency if requestToExternal
// explicitly returns undefined for the given request. Null shortcuts the
// logic such that @wordpress/react-i18n styles are bundled.
if ( request === '@wordpress/react-i18n' ) {
return null;
}
},
} ),
],
};
}
module.exports = getWebpackConfig;
|