-
Notifications
You must be signed in to change notification settings - Fork 66
/
Copy pathwebpack.config.js
39 lines (34 loc) · 1.12 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
/**
**** WARNING: No ES6 modules here. Not transpiled! ****
*/
/* eslint-disable import/no-nodejs-modules, @typescript-eslint/no-var-requires */
/**
* External dependencies
*/
const fs = require( 'fs' );
const getBaseWebpackConfig = require( 'newspack-scripts/config/getWebpackConfig' );
const path = require( 'path' );
// Add all js/src/*.js scripts
const entry = fs
.readdirSync( path.join( __dirname, 'newspack-theme/js', 'src' ) )
.filter( script => 'js' === script.split( '.' ).pop() )
.reduce( ( obj, item ) => {
const split = item.split( '.' );
split.pop();
return {
...obj,
[ split.join( '.' ) ]: path.join( __dirname, 'newspack-theme/js', 'src', item ),
};
}, {} );
// Add all js/src/*/index.js scripts
fs.readdirSync( path.join( __dirname, 'newspack-theme/js', 'src' ) )
.filter( script =>
fs.existsSync( path.join( __dirname, 'newspack-theme/js', 'src', script, 'index.js' ) )
)
.forEach( function ( script ) {
entry[ script ] = path.join( __dirname, 'newspack-theme/js', 'src', script, 'index.js' );
} );
const webpackConfig = getBaseWebpackConfig( {
entry,
} );
module.exports = webpackConfig;