-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.mjs
55 lines (49 loc) · 1.69 KB
/
rollup.config.mjs
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
51
52
53
54
55
import fs from 'fs';
import path from 'path';
import commonjs from '@rollup/plugin-commonjs';
import typescript from '@rollup/plugin-typescript';
import copy from 'rollup-plugin-copy';
import remove from 'rollup-plugin-delete';
const packageJson = JSON.parse(fs.readFileSync('./package.json').toString());
const tsConfigPath = './tsconfig.json';
export const configFor = (moduleFormat, inputFile, outputFile, extraPlugins = [], extraExternal = []) => {
const fullInputFile = path.resolve(inputFile);
const fullOutputFile = path.resolve(outputFile);
const fullOutputFolder = path.resolve(path.dirname(outputFile));
return {
input: fullInputFile,
output: [
{
sourcemap: true,
file: fullOutputFile,
format: moduleFormat
}
],
preserveSymlinks: true,
plugins: [
typescript({
tsconfig: tsConfigPath,
compilerOptions: {
declarationDir: fullOutputFolder
}
}),
commonjs(),
copy({
targets: [{ src: './src/@i18n', dest: fullOutputFolder }]
}),
remove({ targets: path.join(fullOutputFolder, '@i18n', 'index.ts') }),
...extraPlugins
],
external: [/@gobstones\/.*/, /i18next.*/, ...extraExternal]
};
};
export default [
// Starting TypeDoc 0.27 plugins and themes are ESM Only
configFor(
'esm',
'src/index.tsx',
packageJson.exports['.'].import.default,
[],
['assert', 'fs', 'path', 'url', /^typedoc.*/, 'typedoc-plugin-mdn-links', 'typedoc-plugin-merge-modules']
)
];