-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
45 lines (42 loc) · 1.28 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
import config from '@pictogrammers/element-webpack';
import createIndex from './scripts/createIndex.js';
const bold = (text) => '\x1b[1m' + text + '\x1b[0m';
const green = (text) => '\x1b[32m' + text + '\x1b[0m';
const red = (text) => '\x1b[31m' + text + '\x1b[0m';
export default config({
port: 3000,
dist: 'dist',
index: (components, args, mode) => {
return createIndex(components, mode);
},
watch: [],
copy: [
{ from: "api/", to: `api/` }
],
before: (components, args, mode) => {
// Components + GreenText(# of Components)
console.log('Components', bold(green(components.length)));
const filteredComponents = args;
if (filteredComponents.length) {
let exists = [], invalid = [];
components.forEach(({ name }) => {
if (filteredComponents.includes(name)) {
exists.push(name);
} else {
invalid.push(name);
}
});
console.log(' +', ...(exists.map(name => green(name))));
console.log(' -', ...(invalid.map(name => red(name))));
// Remove invalid components
for(let i = components.length - 1; i >= 0; i--) {
if (invalid.includes(components[i].name)) {
components.splice(i, 1);
}
}
}
},
after: (components, args, mode) => {
// Nothing
}
});