-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrollup.config.js
More file actions
99 lines (97 loc) · 2.89 KB
/
Copy pathrollup.config.js
File metadata and controls
99 lines (97 loc) · 2.89 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
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
89
90
91
92
93
94
95
96
97
98
99
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import esbuild from 'rollup-plugin-esbuild';
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
import postcss from 'rollup-plugin-postcss';
import dts from 'rollup-plugin-dts';
import alias from '@rollup/plugin-alias';
import image from '@rollup/plugin-image';
import path from 'path';
import { readFileSync } from 'fs';
import { fileURLToPath } from 'url';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const packageJson = JSON.parse(readFileSync('./package.json', 'utf8'));
export default [
{
input: 'src/index.ts',
output: [
{
file: packageJson.main,
format: 'cjs',
sourcemap: true,
inlineDynamicImports: true,
},
{
file: packageJson.module,
format: 'esm',
sourcemap: true,
inlineDynamicImports: true,
},
],
plugins: [
peerDepsExternal(),
image(),
alias({
entries: [
{ find: '@', replacement: path.resolve(__dirname, 'src') }
]
}),
esbuild({
include: /\.[jt]sx?$/,
exclude: /node_modules/,
target: 'es2020',
jsx: 'transform',
jsxFactory: 'React.createElement',
jsxFragment: 'React.Fragment',
tsconfig: './tsconfig.json',
loaders: {
'.json': 'json',
'.js': 'jsx',
},
}),
resolve({
browser: true,
extensions: ['.ts', '.tsx', '.js', '.jsx', '.json'],
}),
commonjs(),
postcss({
extract: true,
minimize: true,
}),
],
onwarn(warning, warn) {
// Suppress warnings from external packages (node_modules) only
if (warning.id && warning.id.includes('node_modules')) {
return;
}
// Suppress "use client" directives from external packages
if (warning.code === 'MODULE_LEVEL_DIRECTIVE' && warning.id && warning.id.includes('node_modules')) {
return;
}
// Suppress circular dependencies from external packages
if (warning.code === 'CIRCULAR_DEPENDENCY' && warning.message && warning.message.includes('node_modules')) {
return;
}
// Suppress "this" rewritten warnings from external packages
if (warning.code === 'THIS_IS_UNDEFINED' && warning.id && warning.id.includes('node_modules')) {
return;
}
// Show all other warnings (from our source code)
warn(warning);
},
external: ['react', 'react-dom', 'react/jsx-runtime', 'wagmi', 'viem', '@tanstack/react-query', '@tanstack/query-core', 'zustand'],
},
{
input: 'dist/index.d.ts',
output: [{ file: 'dist/index.d.ts', format: 'esm' }],
plugins: [
alias({
entries: [
{ find: '@', replacement: path.resolve(__dirname, 'dist') }
]
}),
dts()
],
external: [/\.css$/],
},
];