-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
51 lines (47 loc) · 1.17 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
44
45
46
47
48
49
50
51
const defaultScriptsConfig = require( '@wordpress/scripts/config/webpack.config' );
const glob = require( 'glob' );
require( 'dotenv' ).config();
const wpScriptsModules = [ 'custom-status', 'editorial-metadata', 'preview', 'settings' ];
const wpScriptsModulesGlob =
wpScriptsModules.length === 1 ? wpScriptsModules[ 0 ] : `{${ wpScriptsModules.join( ',' ) }}`;
const wpScriptsModulesEntries = glob
.sync( `./modules/${ wpScriptsModulesGlob }/lib/*.js` )
.reduce( ( acc, item ) => {
const name = item.replace( /modules\/(.*)\/lib\/(.*).js/, '$1/$2' );
acc[ `${ name }` ] = `./${ item }`;
return acc;
}, {} );
const host = process.env.HOST || 'localhost';
module.exports = [
{
...defaultScriptsConfig,
entry: {
...wpScriptsModulesEntries,
},
module: {
...defaultScriptsConfig.module,
rules: [
...defaultScriptsConfig.module.rules,
{
test: /\.tsx?$/,
use: [
{
loader: 'ts-loader',
options: {
transpileOnly: true,
},
},
],
},
],
},
output: {
...defaultScriptsConfig.output,
path: __dirname + '/dist/modules/',
},
devServer: {
...defaultScriptsConfig.devServer,
host,
},
},
];