Files
v10/packages/react/react-icons/rollup.config.js
T
2025-09-22 23:39:30 +10:00

69 lines
1.7 KiB
JavaScript

const typescript = require('@rollup/plugin-typescript');
const resolve = require('@rollup/plugin-node-resolve');
const commonjs = require('@rollup/plugin-commonjs');
module.exports = [
// ESM build
{
input: 'src/index.ts',
output: {
file: 'dist/index.mjs',
format: 'esm',
sourcemap: true,
},
watch: {
clearScreen: false,
},
external: (id) => {
// Don't externalize relative imports (starts with . or /)
if (id.startsWith('.') || id.startsWith('/')) return false;
// Don't externalize absolute paths (local files)
if (id.includes('/') && !id.startsWith('@')) return false;
// Externalize all npm packages (including scoped ones)
return true;
},
plugins: [
resolve({
extensions: ['.js', '.jsx', '.ts', '.tsx'],
}),
commonjs(),
typescript({
tsconfig: 'tsconfig.json',
declaration: false,
outDir: 'dist',
}),
],
},
// CommonJS build
{
input: 'src/index.ts',
output: {
file: 'dist/index.js',
format: 'cjs',
sourcemap: true,
},
watch: {
clearScreen: false,
},
external: (id) => {
// Don't externalize relative imports (starts with . or /)
if (id.startsWith('.') || id.startsWith('/')) return false;
// Don't externalize absolute paths (local files)
if (id.includes('/') && !id.startsWith('@')) return false;
// Externalize all npm packages (including scoped ones)
return true;
},
plugins: [
resolve({
extensions: ['.js', '.jsx', '.ts', '.tsx'],
}),
commonjs(),
typescript({
tsconfig: 'tsconfig.json',
declaration: false,
outDir: 'dist',
}),
],
},
];