-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathwebpack.config.ts
57 lines (48 loc) · 1.26 KB
/
webpack.config.ts
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
import { Configuration, Entry } from 'webpack';
import { readdirSync } from 'fs-extra';
import { resolve } from 'path';
import CopyPlugin from 'copy-webpack-plugin';
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
const handlers: Entry = {};
readdirSync('./src/handlers')
.filter((file) => file.endsWith('-handler.ts'))
.forEach(function (handler) {
handlers[handler.split('.ts')[0]] = './handlers/' + handler;
});
const config: Configuration = {
mode: 'production',
target: 'node',
devtool: 'nosources-source-map',
context: resolve(__dirname, 'src'),
entry: handlers,
externals: [
'pino-pretty', // https://github.com/pinojs/pino/issues/688
],
output: {
path: resolve(__dirname, 'dist/webpack'),
filename: '[name]/app.js',
libraryTarget: 'commonjs',
clean: true,
},
resolve: {
extensions: ['.ts', '.js'],
},
module: {
rules: [
{
test: /\.ts/,
use: 'ts-loader',
},
],
},
plugins: [
new CopyPlugin({
patterns: Object.keys(handlers).map((handler) => ({ from: '../package-empty.json', to: `${handler}/package.json` })),
}),
new BundleAnalyzerPlugin({
analyzerMode: 'disabled',
generateStatsFile: true,
}),
],
};
export default config;