-
Notifications
You must be signed in to change notification settings - Fork 1
/
rollup.config.js
45 lines (42 loc) · 1.29 KB
/
rollup.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 { join } from 'path';
import { readFileSync } from 'fs';
import { yamlParse } from 'yaml-cfn';
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import nodeResolve from '@rollup/plugin-node-resolve';
import typescript from '@rollup/plugin-typescript';
import { terser } from 'rollup-plugin-terser';
const defaultConfig = {
plugins: [
nodeResolve({
preferBuiltins: true,
// TODO: remove this workaround for @octokit/auth-app.js
// see https://github.com/octokit/auth-app.js/issues/59#issuecomment-833985009
mainFields: ['main', 'module'],
}),
typescript(),
commonjs(),
json(),
],
input: 'src/index.ts',
external: ['aws-sdk'],
output: {
plugins: [terser()],
},
};
const { Resources } = yamlParse(readFileSync('template.yml'));
const entries = Object.values(Resources)
.filter((resource) => resource.Type == 'AWS::Serverless::Function')
.filter((resource) => resource.Properties.Runtime.startsWith('nodejs'))
.map((resource) => {
const file = resource.Properties.Handler.split('.')[0];
return {
...defaultConfig,
output: {
...defaultConfig.output,
format: 'cjs',
file: join('.', resource.Properties.CodeUri, `${file}.js`),
},
};
});
export default entries;