generated from obsidianmd/obsidian-sample-plugin
-
Notifications
You must be signed in to change notification settings - Fork 9
/
rollup.config.mjs
60 lines (55 loc) · 1.41 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
56
57
58
59
60
// ---------------------------------------------------------------------------------------------------------------------
// This is the configuration file for building the API package.
// ---------------------------------------------------------------------------------------------------------------------
import typescript from '@rollup/plugin-typescript';
import dts from 'rollup-plugin-dts';
import prettier from 'rollup-plugin-prettier';
import { external, outdir } from './build.config.mjs';
const entry = './api/index.ts';
const config = [
// API Type Declarations
{
input: entry,
output: [{ file: `${outdir}/api.d.ts`, format: 'es' }],
external,
plugins: [
typescript({
compilerOptions: {
outDir: 'dist',
sourceMap: false,
inlineSources: false,
inlineSourceMap: false,
},
}),
dts(),
prettier({
parser: 'typescript',
}),
],
},
// API Runtime
buildApi('commonjs', 'api-cjs.js'),
buildApi('es', 'api-esm.mjs'),
buildApi('es', 'api-esm-esnext.mjs', {
typescript: {
target: 'esnext',
},
}),
];
export default config;
function buildApi(format, filename, options) {
return {
input: entry,
output: [{ file: `${outdir}/${filename}`, format }],
external,
plugins: [
prettier({ parser: 'babel' }),
typescript({
tsconfig: 'api/tsconfig.json',
inlineSources: false,
inlineSourceMap: false,
...(options?.typescript ?? {}),
}),
],
};
}