LibreChat/packages/client/rollup.config.js
Danny Avila f8738b207c
feat: update client package configuration and dependencies
- Added new dependencies for Rollup plugins and updated existing ones in package.json and package-lock.json.
- Introduced a new Rollup configuration file for building the client package.
- Refactored build scripts to include a dedicated build command for the client.
- Updated TypeScript configuration for improved module resolution and type declaration output.
- Integrated a Toast component from the client package into the main App component.
2025-07-26 01:13:50 +02:00

56 lines
1.4 KiB
JavaScript

// ESM bundler config for React components
import typescript from 'rollup-plugin-typescript2';
import resolve from '@rollup/plugin-node-resolve';
import pkg from './package.json';
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
import commonjs from '@rollup/plugin-commonjs';
import replace from '@rollup/plugin-replace';
import terser from '@rollup/plugin-terser';
import alias from '@rollup/plugin-alias';
import { fileURLToPath } from 'url';
import { dirname, resolve as pathResolve } from 'path';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const plugins = [
peerDepsExternal(),
alias({
entries: [{ find: '~', replacement: pathResolve(__dirname, 'src') }],
}),
resolve({
extensions: ['.js', '.jsx', '.ts', '.tsx'],
}),
replace({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'production'),
preventAssignment: true,
}),
commonjs(),
typescript({
tsconfig: './tsconfig.json',
useTsconfigDeclarationDir: true,
clean: true,
}),
terser(),
];
export default {
input: 'src/index.ts',
output: [
{
file: pkg.main,
format: 'cjs',
sourcemap: true,
exports: 'named',
},
{
file: pkg.module,
format: 'esm',
sourcemap: true,
exports: 'named',
},
],
external: [...Object.keys(pkg.peerDependencies || {}), 'react/jsx-runtime'],
preserveSymlinks: true,
plugins,
};