-
Notifications
You must be signed in to change notification settings - Fork 33
/
webpack.config.pro.js
60 lines (55 loc) · 1.69 KB
/
webpack.config.pro.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
const { BundleAnalyzerPlugin } = require( 'webpack-bundle-analyzer' );
const defaultConfig = require( '@wordpress/scripts/config/webpack.config' );
const NODE_ENV = process.env.NODE_ENV || 'development';
const ANALYZER = 'true' === process.env.NODE_ANALYZER ? true : false;
const path = require( 'path' );
const FileManagerPlugin = require( 'filemanager-webpack-plugin' );
const blocks = require( './blocks.json' );
defaultConfig.plugins.splice( 1, 1 ); // We need to remove Core's Copy Files plugin.
const blockFilesPro = Object.keys( blocks ).filter( block => blocks[ block ].block !== undefined && true === blocks[ block ]?.isPro )
.map( block => {
return {
source: `src/${ blocks[ block ].block }`,
destination: `build/pro/${ block }/`
};
});
const blockFoldersPro = Object.keys( blocks ).filter( block => true === blocks[ block ]?.isPro ).map( block => `build/pro/${ block }` );
module.exports = [
{
// OTTER PRO
...defaultConfig,
stats: 'minimal',
devtool: 'development' === NODE_ENV ? 'eval-source-map' : undefined,
mode: NODE_ENV,
entry: {
blocks: [
'./src/pro/blocks/index.js',
'./src/pro/plugins/index.js'
],
dashboard: './src/pro/dashboard/index.js',
woocommerce: './src/pro/woocommerce/index.js'
},
output: {
path: path.resolve( __dirname, './build/pro' ),
filename: '[name].js',
chunkFilename: 'chunk-[name].js'
},
plugins: [
...defaultConfig.plugins,
new FileManagerPlugin({
events: {
onEnd: {
mkdir: blockFoldersPro,
copy: blockFilesPro
}
},
runOnceInWatchMode: false,
runTasksInSeries: true
}),
new BundleAnalyzerPlugin({
analyzerMode: 'disabled',
generateStatsFile: ANALYZER
})
]
}
];