2024-03-06 21:03:12 +01:00
|
|
|
import plugins from '@lucide/rollup-plugins';
|
2025-01-10 14:35:28 +01:00
|
|
|
import preserveDirectives from 'rollup-plugin-preserve-directives';
|
2022-11-07 22:29:19 +01:00
|
|
|
import pkg from './package.json' assert { type: 'json' };
|
2024-02-01 22:38:21 +09:00
|
|
|
import dts from 'rollup-plugin-dts';
|
2023-08-13 22:07:54 +02:00
|
|
|
import getAliasesEntryNames from './scripts/getAliasesEntryNames.mjs';
|
|
|
|
|
|
2024-02-01 22:38:21 +09:00
|
|
|
const aliasesEntries = await getAliasesEntryNames();
|
2020-12-02 13:48:39 +01:00
|
|
|
|
2021-02-22 20:26:38 +01:00
|
|
|
const packageName = 'LucideReact';
|
|
|
|
|
const outputFileName = 'lucide-react';
|
2022-08-10 09:10:53 +02:00
|
|
|
const outputDir = `dist`;
|
2022-12-04 22:38:56 +01:00
|
|
|
const inputs = [`src/lucide-react.ts`];
|
2020-12-02 13:48:39 +01:00
|
|
|
const bundles = [
|
|
|
|
|
{
|
|
|
|
|
format: 'umd',
|
|
|
|
|
inputs,
|
|
|
|
|
outputDir,
|
|
|
|
|
minify: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
format: 'umd',
|
|
|
|
|
inputs,
|
|
|
|
|
outputDir,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
format: 'cjs',
|
|
|
|
|
inputs,
|
|
|
|
|
outputDir,
|
2022-12-04 22:38:56 +01:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
format: 'esm',
|
2024-02-01 22:38:21 +09:00
|
|
|
inputs: [...inputs, ...aliasesEntries],
|
2022-12-04 22:38:56 +01:00
|
|
|
outputDir,
|
|
|
|
|
preserveModules: true,
|
|
|
|
|
},
|
2023-08-06 15:47:07 +02:00
|
|
|
{
|
|
|
|
|
format: 'esm',
|
2025-01-10 14:35:28 +01:00
|
|
|
inputs: ['src/dynamic.ts', 'src/dynamicIconImports.ts', 'src/DynamicIcon.ts'],
|
|
|
|
|
outputDir,
|
|
|
|
|
preserveModules: true,
|
2023-08-06 15:47:07 +02:00
|
|
|
external: [/src/],
|
|
|
|
|
paths: (id) => {
|
|
|
|
|
if (id.match(/src/)) {
|
2024-02-01 22:38:21 +09:00
|
|
|
const [, modulePath] = id.match(/src\/(.*)\.ts/);
|
2023-08-06 15:47:07 +02:00
|
|
|
|
2025-01-10 14:35:28 +01:00
|
|
|
return `${modulePath}.js`;
|
2023-08-06 15:47:07 +02:00
|
|
|
}
|
2024-02-01 22:38:21 +09:00
|
|
|
},
|
2023-08-06 15:47:07 +02:00
|
|
|
},
|
2020-12-02 13:48:39 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const configs = bundles
|
2024-02-01 22:38:21 +09:00
|
|
|
.map(
|
|
|
|
|
({
|
|
|
|
|
inputs,
|
|
|
|
|
outputDir,
|
|
|
|
|
outputFile,
|
|
|
|
|
format,
|
|
|
|
|
minify,
|
|
|
|
|
preserveModules,
|
|
|
|
|
entryFileNames,
|
|
|
|
|
external = [],
|
|
|
|
|
paths,
|
|
|
|
|
}) =>
|
|
|
|
|
inputs.map((input) => ({
|
|
|
|
|
input,
|
2025-01-10 14:35:28 +01:00
|
|
|
plugins: [
|
|
|
|
|
...plugins({ pkg, minify }),
|
|
|
|
|
// Make sure we emit "use client" directive to make it compatible with Next.js
|
|
|
|
|
preserveDirectives({
|
|
|
|
|
include: 'src/DynamicIcon.ts',
|
|
|
|
|
suppressPreserveModulesWarning: true,
|
|
|
|
|
}),
|
|
|
|
|
],
|
2024-02-01 22:38:21 +09:00
|
|
|
external: ['react', 'prop-types', ...external],
|
|
|
|
|
output: {
|
|
|
|
|
name: packageName,
|
|
|
|
|
...(preserveModules
|
|
|
|
|
? {
|
|
|
|
|
dir: `${outputDir}/${format}`,
|
|
|
|
|
}
|
|
|
|
|
: {
|
|
|
|
|
file:
|
|
|
|
|
outputFile ??
|
|
|
|
|
`${outputDir}/${format}/${outputFileName}${minify ? '.min' : ''}.js`,
|
|
|
|
|
}),
|
|
|
|
|
paths,
|
|
|
|
|
entryFileNames,
|
|
|
|
|
format,
|
|
|
|
|
sourcemap: true,
|
|
|
|
|
preserveModules,
|
2024-03-06 21:03:12 +01:00
|
|
|
preserveModulesRoot: 'src',
|
2024-02-01 22:38:21 +09:00
|
|
|
globals: {
|
|
|
|
|
react: 'react',
|
|
|
|
|
'prop-types': 'PropTypes',
|
|
|
|
|
},
|
2020-12-02 13:48:39 +01:00
|
|
|
},
|
2024-02-01 22:38:21 +09:00
|
|
|
})),
|
2020-12-02 13:48:39 +01:00
|
|
|
)
|
|
|
|
|
.flat();
|
|
|
|
|
|
2023-07-13 16:39:02 +02:00
|
|
|
export default [
|
2023-07-19 19:32:34 +02:00
|
|
|
{
|
|
|
|
|
input: 'src/dynamicIconImports.ts',
|
2024-02-01 22:38:21 +09:00
|
|
|
output: [
|
|
|
|
|
{
|
2025-01-10 14:35:28 +01:00
|
|
|
file: `dist/dynamicIconImports.d.ts`,
|
|
|
|
|
format: 'es',
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
plugins: [
|
|
|
|
|
dts({
|
|
|
|
|
exclude: ['./src/icons'],
|
|
|
|
|
}),
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
input: 'src/dynamic.ts',
|
|
|
|
|
output: [
|
|
|
|
|
{
|
|
|
|
|
file: `dist/dynamic.d.ts`,
|
|
|
|
|
format: 'es',
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
plugins: [dts()],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
input: 'src/DynamicIcon.ts',
|
|
|
|
|
output: [
|
|
|
|
|
{
|
|
|
|
|
file: `dist/DynamicIcon.d.ts`,
|
2024-02-01 22:38:21 +09:00
|
|
|
format: 'es',
|
|
|
|
|
},
|
|
|
|
|
],
|
2023-07-19 19:32:34 +02:00
|
|
|
plugins: [dts()],
|
|
|
|
|
},
|
2023-07-13 16:39:02 +02:00
|
|
|
{
|
|
|
|
|
input: inputs[0],
|
2024-02-01 22:38:21 +09:00
|
|
|
output: [
|
|
|
|
|
{
|
|
|
|
|
file: `dist/${outputFileName}.d.ts`,
|
|
|
|
|
format: 'es',
|
|
|
|
|
},
|
|
|
|
|
],
|
2023-07-13 16:39:02 +02:00
|
|
|
plugins: [dts()],
|
|
|
|
|
},
|
2024-11-08 16:47:53 +01:00
|
|
|
{
|
|
|
|
|
input: `src/${outputFileName}.suffixed.ts`,
|
|
|
|
|
output: [
|
|
|
|
|
{
|
|
|
|
|
file: `dist/${outputFileName}.suffixed.d.ts`,
|
|
|
|
|
format: 'es',
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
plugins: [dts()],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
input: `src/${outputFileName}.prefixed.ts`,
|
|
|
|
|
output: [
|
|
|
|
|
{
|
|
|
|
|
file: `dist/${outputFileName}.prefixed.d.ts`,
|
|
|
|
|
format: 'es',
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
plugins: [dts()],
|
|
|
|
|
},
|
2024-02-01 22:38:21 +09:00
|
|
|
...configs,
|
2023-07-13 16:39:02 +02:00
|
|
|
];
|