-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrollup.config.js
More file actions
57 lines (55 loc) · 1.35 KB
/
Copy pathrollup.config.js
File metadata and controls
57 lines (55 loc) · 1.35 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
51
52
53
54
55
56
57
import typescript from 'rollup-plugin-typescript2';
import postcss from 'rollup-plugin-postcss';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import { readFileSync } from 'fs';
import { createRequire } from 'module';
const require = createRequire(import.meta.url);
const pkg = JSON.parse(readFileSync('./package.json', 'utf-8'));
export default {
// Single bundle with everything
input: 'src/index.ts',
output: [
{
file: pkg.main,
format: 'cjs',
exports: 'named',
sourcemap: true,
inlineDynamicImports: true,
},
{
file: pkg.module,
format: 'esm',
exports: 'named',
sourcemap: true,
inlineDynamicImports: true,
},
],
external: [
'react',
'react/jsx-runtime',
'react-dom',
...Object.keys(pkg.dependencies || {})
],
plugins: [
nodeResolve({
browser: true,
preferBuiltins: false,
// Resolve non-React dependencies only
exclude: ['react', 'react-dom', 'react/jsx-runtime']
}),
commonjs({
// Transform non-React dependencies only
ignore: ['react', 'react-dom', 'react/jsx-runtime']
}),
postcss({
extract: false,
inject: true,
minimize: true,
}),
typescript({
typescript: require('typescript'),
clean: true,
}),
],
};