forked from spryker-shop/suite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompiler.js
47 lines (38 loc) · 1.51 KB
/
compiler.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
const webpack = require('webpack');
const { buildVariantSettings } = require('../settings');
// execute webpack compiler on array of configurations
// and nicely handle the console output
const multiCompile = configs => {
if (!configs || !configs.length) {
return console.error('Nothing to build. Build aborted.');
}
configs.forEach(config => {
const buildVariant = buildVariantSettings.buildVariant;
console.log(`${config.namespace} (${config.theme}) building ${buildVariant} modules for ${config.webpack.mode}...`);
if (config.webpack.watch) {
console.log(`${config.namespace} (${config.theme}) watch mode: ON`);
}
});
const webpackConfigs = configs.map(item => item.webpack);
webpack(webpackConfigs, (err, multiStats) => {
if (err) {
console.error(err.stack || err);
if (err.details) {
console.error(err.details);
}
return;
}
multiStats.stats.forEach(
(stat, index) => {
console.log(`${configs[index].namespace} namespace building statistics:`);
console.log(`Theme: ${configs[index].theme}`);
console.log(`Components entry points: ${configs[index].componentEntryPointsLength}`);
console.log(`Components styles: ${configs[index].stylesLength}`);
console.log(stat.toString(webpackConfigs[index].stats), '\n')
}
);
});
};
module.exports = {
multiCompile
};