-
Notifications
You must be signed in to change notification settings - Fork 146
/
webpack.config.js
71 lines (61 loc) · 1.89 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/**
* WordPress dependencies
*/
const defaultConfig = require( '@wordpress/scripts/config/webpack.config' );
/**
* External dependencies
*/
const RtlCssPlugin = require( 'rtlcss-webpack-plugin' );
const path = require( 'path' );
const fs = require( 'fs' );
const scripts = [
'coblocks-accordion-polyfill',
'coblocks-animation',
'coblocks-checkbox-required',
'coblocks-counter-script',
'coblocks-events-script',
'coblocks-fromEntries',
'coblocks-google-maps',
'coblocks-google-recaptcha',
'coblocks-lightbox',
'coblocks-masonry',
'coblocks-post-carousel-script',
'coblocks-services-script',
'coblocks-tinyswiper-initializer',
'coblocks-gist-script',
];
const coblocksEntries = fs.readdirSync( path.resolve( process.cwd(), 'src' ) ).filter( ( file ) => file.startsWith( 'blocks-' ) );
const coblocksChunks = coblocksEntries.reduce(
( a, file ) => ( { ...a, [ 'co' + file.replace( '.js', '' ) ]: path.resolve( process.cwd(), `src/${ file }` ) } ),
{}
);
module.exports = {
...defaultConfig,
entry: {
...coblocksChunks,
'coblocks-extensions': path.resolve( process.cwd(), 'src/extensions.js' ),
'coblocks-plugin-deactivation': path.resolve( process.cwd(), 'src/components/coblocks-deactivate-modal/index.js' ),
'style-coblocks-animation': path.resolve( process.cwd(), 'src/styles/coblocks-animation.scss' ),
...scripts.reduce( ( memo, script ) => {
memo[ `js/${ script }` ] = path.resolve( process.cwd(), 'src', 'js', `${ script }.js` );
return memo;
}, {} ),
// Vendors
'js/vendors/tiny-swiper': path.resolve( process.cwd(), 'node_modules/tiny-swiper/lib/index.js' ),
},
output: {
...defaultConfig.output,
path: path.resolve( process.cwd(), 'dist/' ),
publicPath: 'auto',
},
plugins: [
...defaultConfig.plugins,
new RtlCssPlugin( {
filename: '[name]-rtl.css',
} ),
],
};
// Set parallelism to 1 in CircleCI.
if ( process.env.CI ) {
module.exports.parallelism = 1;
}