forked from bdalpe/cribl-content
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
63 lines (60 loc) · 1.64 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
const {readdirSync} = require('fs');
const {join, resolve} = require('path');
const webpack = require('webpack');
const TerserPlugin = require('terser-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const folders = ['collectors', 'functions'];
const dirs = () => folders.map(entry => {
return readdirSync(join(__dirname, entry), {withFileTypes: true})
.filter(dirent => dirent.isDirectory())
.map(dirent => dirent.name)
.map(subentry => {
return `./${join(entry, subentry, 'index.js')}`;
})
}).flat().reduce((acc, path) => {
const entry = path.replace('/index.js', '');
acc[entry] = path;
return acc;
}, {});
module.exports = {
optimization: {
minimize: true,
minimizer: [new TerserPlugin({
terserOptions: {
compress: true,
format: {
comments: false
}
}
})],
},
target: 'node',
mode: "production",
entry: dirs,
output: {
filename: './[name]/index.js',
path: resolve(__dirname, 'dist'),
libraryTarget: "commonjs",
},
node: {
global: false
},
plugins: [
new CopyPlugin({
patterns: [
{
from: './*/*/conf.*.json',
to: './'
},
{
from: './*/*/*.md',
to: './'
}
]
}),
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer']
}),
new webpack.IgnorePlugin({ resourceRegExp: /^pg-native$/ })
]
}