-
Notifications
You must be signed in to change notification settings - Fork 46
/
dts-config.js
43 lines (37 loc) · 1017 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
const fs = require('fs')
const pluginsDir = './src/js/plugins'
const helpersDir = './src/js/helpers'
const distDir = './dist/js'
const excludePlugins = ['base-plugin']
const outputConfig = { noBanner: true }
const config = {
compilationOptions: {
preferredConfigPath: './tsconfig.json'
},
entries: [
{
filePath: './src/js/index.ts',
outFile: './dist/js/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