forked from stoplightio/spectral
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
50 lines (42 loc) · 1.17 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
46
47
48
49
50
import typescript from 'rollup-plugin-typescript2';
import * as path from 'path';
import * as fs from 'fs';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import { terser } from 'rollup-plugin-terser';
const BASE_PATH = process.cwd();
const functions = [];
const builtIns = ['oas', 'asyncapi'];
for (const rulesetName of builtIns) {
const targetDir = path.join(BASE_PATH, `dist/rulesets/${rulesetName}/functions/`);
if (!fs.existsSync(targetDir)) {
continue;
}
for (const file of fs.readdirSync(targetDir)) {
const targetFile = path.join(targetDir, file);
const stat = fs.statSync(targetFile);
if (!stat.isFile()) continue;
const ext = path.extname(targetFile);
if (ext !== '.js') continue;
functions.push(targetFile);
}
}
module.exports = functions.map(fn => ({
input: fn,
plugins: [
typescript({
tsconfig: path.join(BASE_PATH, './tsconfig.rollup.json'),
include: ['dist/**/*.{ts,tsx}'],
}),
resolve(),
commonjs(),
json(),
terser(),
],
output: {
file: fn,
format: 'cjs',
exports: 'named',
},
}));