-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrollup.config.js
More file actions
50 lines (48 loc) · 1.36 KB
/
rollup.config.js
File metadata and controls
50 lines (48 loc) · 1.36 KB
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 terser from '@rollup/plugin-terser';
// rollup.config.js
import typescript from '@rollup/plugin-typescript';
import { globSync } from 'glob';
import copy from 'rollup-plugin-copy';
// Find all TypeScript files in 'src', excluding declaration files.
const entryPoints = globSync('src/**/*.ts', {
ignore: ['src/**/*.d.ts', 'src/**/__tests__/**'], // Ignore declaration files and all __tests__ folders
});
export default {
input: entryPoints,
output: [
{
dir: 'dist',
entryFileNames: '[name].cjs',
format: 'cjs',
exports: 'named',
// Preserve the original module structure.
preserveModules: true,
// Set 'src' as the root. This strips 'src/' from the output path.
// e.g., 'src/configs/main.ts' becomes 'dist/configs/main.cjs'
preserveModulesRoot: 'src',
},
{
dir: 'dist',
entryFileNames: '[name].js',
format: 'es',
preserveModules: true,
preserveModulesRoot: 'src',
},
],
plugins: [
typescript({
tsconfig: './tsconfig.build.json',
// Ensure declaration files also respect the directory structure.
declaration: true,
declarationDir: 'dist',
rootDir: 'src',
}),
terser(),
copy({
targets: [
{ src: 'src/tsconfig-base.json', dest: 'dist' },
{ src: 'src/markdownlint.json', dest: 'dist' },
],
}),
],
};