-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathwebpack.config.js
43 lines (39 loc) · 1000 Bytes
/
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
/**
* External dependencies
*/
const CopyWebpackPlugin = require( 'copy-webpack-plugin' );
const { escapeRegExp } = require( 'lodash' );
const { join, sep } = require( 'path' );
const defaultConfig = require( '@wordpress/scripts/config/webpack.config' );
const RtlCssPlugin = require( 'rtlcss-webpack-plugin' );
module.exports = {
...defaultConfig,
plugins: [
...defaultConfig.plugins.filter(
( filter ) => ! ( filter instanceof RtlCssPlugin )
),
// Copy utility files to build.
new CopyWebpackPlugin( {
patterns: [].concat(
Object.entries( {
'src': '',
} ).flatMap( ( [ from, to ] ) => [
{
from: `${ from }/**/utils.php`,
to( { absoluteFilename } ) {
const [ , dirname ] = absoluteFilename.match(
new RegExp(
`([\\w-]+)${ escapeRegExp(
sep
) }utils\\.php$`
)
);
return join( to, `${ dirname }/utils.php` );
},
noErrorOnMissing: true,
},
] )
),
} ),
],
};