-
Notifications
You must be signed in to change notification settings - Fork 7
/
webpack.config.js
43 lines (41 loc) · 1.16 KB
/
webpack.config.js
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
const path = require( 'path' );
/**
* WordPress Dependencies
*/
const defaultConfig = require( '@wordpress/scripts/config/webpack.config.js' );
const DependencyExtractionWebpackPlugin = require( '@wordpress/dependency-extraction-webpack-plugin' );
module.exports = {
...defaultConfig,
...{
entry: {
'bp-search-block/index': './src/bp-search-block/index.js',
'bp-search-block/view': './src/bp-search-block/view.js',
},
output: {
filename: '[name].js',
path: path.resolve( __dirname, 'dist' ),
}
},
plugins: [
...defaultConfig.plugins.filter(
( plugin ) =>
plugin.constructor.name !== 'DependencyExtractionWebpackPlugin'
),
new DependencyExtractionWebpackPlugin( {
requestToExternal( request ) {
if ( request === '@buddypress/block-components' ) {
return [ 'bp', 'blockComponents' ];
} else if ( request === '@buddypress/block-data' ) {
return [ 'bp', 'blockData' ];
}
},
requestToHandle( request ) {
if ( request === '@buddypress/block-components' ) {
return 'bp-block-components';
} else if ( request === '@buddypress/block-data' ) {
return 'bp-block-data';
}
}
} )
]
}