-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrollup.config.js
46 lines (44 loc) · 1.4 KB
/
rollup.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
import typescript from '@rollup/plugin-typescript';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import del from 'rollup-plugin-delete';
import { terser } from 'rollup-plugin-terser';
import path from 'path';
const entries = [
'./src/index.ts',
'./src/jest-globals.ts',
'./src/matchers/index.ts',
]
export default CLIArgs => {
const plugins = [
del({ targets: 'dist/*' }),
typescript(), // Compiles TypeScript to JavaScript
resolve(), // Resolves node_modules imports
commonjs(), // Converts CommonJS modules to ES6
];
if (CLIArgs.configMini) {
plugins.push(terser()); // Minify the output (optional)
}
return {
input: entries, // Pointing to your TypeScript entry file
output: [
{
dir: 'dist',
entryFileNames: '[name].mjs',
chunkFileNames: '[name]-[hash].mjs',
format: 'esm',
sourcemap: CLIArgs.sourcemaps,
},
{
dir: 'dist',
entryFileNames: '[name].js',
chunkFileNames: '[name]-[hash].js',
format: 'cjs',
sourcemap: CLIArgs.sourcemaps,
},
],
external: id =>
!id.startsWith('\0') && !id.startsWith('.') && !path.isAbsolute(id),
plugins
}
};