-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
45 lines (40 loc) · 1.18 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
const path = require('path');
const glob = require('glob');
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
const {CleanWebpackPlugin} = require('clean-webpack-plugin');
const ZipPlugin = require('zip-webpack-plugin');
const entryArray = glob.sync('./src/endpoints/**/!(_)*.mjs');
const entryObject = entryArray.reduce((acc, item) => {
let pathName = item.replace('./src/endpoints/', '');
let name =
path.dirname(pathName).replaceAll('/', '.') +
'.' +
path.basename(pathName, '.mjs');
acc[name] = item;
return acc;
}, {});
const ZipPlugins = Object.keys(entryObject).map((name) => {
return new ZipPlugin({
path: path.resolve(__dirname, 'build/artifacts/'),
filename: name,
include: [name],
});
});
module.exports = {
entry: entryObject,
devtool: 'source-map',
target: 'node',
plugins: [new ProgressBarPlugin(), ...ZipPlugins, new CleanWebpackPlugin()],
resolve: {
extensions: ['.js', '.mjs'],
},
externals: /^@aws-sdk\/.+$/,
output: {
filename: '[name]/index.cjs',
library: {
type: 'commonjs',
},
path: path.resolve(__dirname, 'build'),
devtoolModuleFilenameTemplate: '[absolute-resource-path]',
},
};