forked from nvh95/jest-preview
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.mjs
88 lines (83 loc) · 1.92 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import { defineConfig } from 'rollup';
import { builtinModules } from 'module';
import esbuild from 'rollup-plugin-esbuild';
import commonjs from '@rollup/plugin-commonjs';
import dts from 'rollup-plugin-dts';
import nodeResolve from '@rollup/plugin-node-resolve';
import copy from 'rollup-plugin-copy';
import pkg from './package.json' assert { type: 'json' };
const external = [
...builtinModules,
...Object.keys(pkg.dependencies),
...Object.keys(pkg.devDependencies),
];
const plugins = [
nodeResolve({
preferBuiltins: true,
}),
commonjs(),
esbuild({
target: 'node14',
}),
];
function makeBundle({ filePath, dir = 'dist' }) {
return {
input: filePath,
output: {
dir: dir,
format: 'cjs',
},
plugins,
external,
};
}
export default defineConfig([
makeBundle({ filePath: 'src/index.ts' }),
makeBundle({ filePath: 'src/preconfigTransform/css.ts', dir: 'transforms' }),
makeBundle({ filePath: 'src/preconfigTransform/file.ts', dir: 'transforms' }),
makeBundle({
filePath: 'src/preconfigTransform/fileCRA.ts',
dir: 'transforms',
}),
{
input: 'src/cli/index.ts',
output: {
dir: 'dist',
format: 'cjs',
banner: '#!/usr/bin/env node',
entryFileNames: 'cli/index.js',
chunkFileNames: 'cli/[name].js',
},
external,
plugins: [
nodeResolve({
preferBuiltins: true,
}),
esbuild({
target: 'node14',
}),
copy({
targets: [
{
src: [
'src/cli/server/favicon.ico',
'src/cli/server/ws-client.js',
'src/cli/server/browser/openChrome.applescript',
],
dest: 'dist/cli',
},
],
}),
],
},
{
input: 'src/index.ts',
output: {
dir: 'dist',
entryFileNames: `index.d.ts`,
format: 'esm',
},
external,
plugins: [dts({ respectExternal: true })],
},
]);