2023-01-17 08:04:34 +01:00
|
|
|
import plugins, { replace } from '@lucide/rollup-plugins';
|
2022-11-07 22:29:19 +01:00
|
|
|
import pkg from './package.json' assert { type: 'json' };
|
2023-07-13 16:39:02 +02:00
|
|
|
import dts from "rollup-plugin-dts";
|
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,
|
2023-07-13 16:39:02 +02:00
|
|
|
aliasesSupport: true,
|
|
|
|
|
withDynamicImports: true,
|
2022-12-04 22:38:56 +01:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
format: 'esm',
|
|
|
|
|
inputs,
|
|
|
|
|
outputDir,
|
|
|
|
|
preserveModules: true,
|
2023-07-13 16:39:02 +02:00
|
|
|
aliasesSupport: true,
|
|
|
|
|
withDynamicImports: true,
|
2022-12-04 22:38:56 +01:00
|
|
|
},
|
2020-12-02 13:48:39 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const configs = bundles
|
2023-07-13 16:39:02 +02:00
|
|
|
.map(({ inputs, outputDir, format, minify, preserveModules, aliasesSupport, withDynamicImports }) =>
|
2020-12-02 13:48:39 +01:00
|
|
|
inputs.map(input => ({
|
|
|
|
|
input,
|
2023-01-17 08:04:34 +01:00
|
|
|
plugins: [
|
|
|
|
|
...(
|
2023-04-03 21:54:18 +02:00
|
|
|
!aliasesSupport ? [
|
2023-01-17 08:04:34 +01:00
|
|
|
replace({
|
|
|
|
|
"export * from './aliases';": '',
|
|
|
|
|
"export * as icons from './icons';": '',
|
|
|
|
|
delimiters: ['', ''],
|
|
|
|
|
preventAssignment: false,
|
|
|
|
|
}),
|
|
|
|
|
] : []
|
|
|
|
|
),
|
2023-07-13 16:39:02 +02:00
|
|
|
...(
|
|
|
|
|
!withDynamicImports ? [
|
|
|
|
|
replace({
|
|
|
|
|
"export { default as dynamicIconImports } from './dynamicIconImports';": '',
|
|
|
|
|
delimiters: ['', ''],
|
|
|
|
|
preventAssignment: false,
|
|
|
|
|
}),
|
|
|
|
|
] : []
|
|
|
|
|
),
|
2023-01-17 08:04:34 +01:00
|
|
|
...plugins(pkg, minify)
|
|
|
|
|
],
|
2022-12-04 22:38:56 +01:00
|
|
|
external: ['react', 'prop-types'],
|
2020-12-02 13:48:39 +01:00
|
|
|
output: {
|
2021-02-22 20:26:38 +01:00
|
|
|
name: packageName,
|
2022-12-04 22:38:56 +01:00
|
|
|
...(preserveModules
|
|
|
|
|
? {
|
|
|
|
|
dir: `${outputDir}/${format}`,
|
|
|
|
|
}
|
|
|
|
|
: {
|
|
|
|
|
file: `${outputDir}/${format}/${outputFileName}${minify ? '.min' : ''}.js`,
|
|
|
|
|
}),
|
2020-12-02 13:48:39 +01:00
|
|
|
format,
|
|
|
|
|
sourcemap: true,
|
2022-12-04 22:38:56 +01:00
|
|
|
preserveModules,
|
2020-12-02 13:48:39 +01:00
|
|
|
globals: {
|
|
|
|
|
react: 'react',
|
2022-12-04 22:38:56 +01:00
|
|
|
'prop-types': 'PropTypes'
|
2020-12-02 13:48:39 +01:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
})),
|
|
|
|
|
)
|
|
|
|
|
.flat();
|
|
|
|
|
|
2023-07-13 16:39:02 +02:00
|
|
|
export default [
|
|
|
|
|
{
|
|
|
|
|
input: inputs[0],
|
|
|
|
|
output: [{
|
|
|
|
|
file: `dist/${outputFileName}.d.ts`, format: "es"
|
|
|
|
|
}],
|
|
|
|
|
plugins: [dts()],
|
|
|
|
|
},
|
|
|
|
|
...configs
|
|
|
|
|
];
|