-
Notifications
You must be signed in to change notification settings - Fork 320
/
dts-config.js
46 lines (40 loc) · 993 Bytes
/
dts-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
const fs = require('fs');
const pluginsDir = './src/plugins';
const helpersDir = './src/helpers';
const distDir = './dist';
const excludePlugins = ['base-plugin', 'docs-scrollspy'];
const outputConfig = { noBanner: true };
const config = {
compilationOptions: {
preferredConfigPath: './tsconfig.json',
},
entries: [
{
filePath: './src/index.ts',
outFile: './dist/index.d.ts',
output: outputConfig,
},
...fs
.readdirSync(pluginsDir)
.map((pluginName) => writeFile(pluginsDir, pluginName))
.filter(Boolean),
...fs
.readdirSync(helpersDir)
.map((pluginName) => writeFile(helpersDir, pluginName, 'helper-'))
.filter(Boolean),
],
};
function writeFile(dir, plugin, prefix = '') {
if (
!fs.lstatSync(`${dir}/${plugin}`).isDirectory() ||
excludePlugins.includes(plugin)
) {
return null;
}
return {
filePath: `${dir}/${plugin}/index.ts`,
outFile: `${distDir}/${prefix}${plugin}.d.ts`,
output: outputConfig,
};
}
module.exports = config;