2022-11-07 22:29:19 +01:00
|
|
|
import { visualizer } from 'rollup-plugin-visualizer';
|
2023-01-17 08:04:34 +01:00
|
|
|
import replace from '@rollup/plugin-replace';
|
2021-03-23 19:26:50 +01:00
|
|
|
import license from 'rollup-plugin-license';
|
2022-12-04 22:38:56 +01:00
|
|
|
import esbuild from 'rollup-plugin-esbuild';
|
2024-03-06 21:03:12 +01:00
|
|
|
import { nodeResolve } from '@rollup/plugin-node-resolve';
|
2025-11-27 10:50:19 +01:00
|
|
|
import summary from 'rollup-plugin-summary';
|
2020-12-02 13:48:39 +01:00
|
|
|
|
2026-11-12 12:20:16 +05:00
|
|
|
/**
|
|
|
|
|
* Wraps a plugin's `renderChunk` hook so it is skipped for chunks matching `exclude`.
|
|
|
|
|
* Used to keep the license banner to a single chunk that every consumer path imports,
|
|
|
|
|
* instead of repeating it in every module emitted with `preserveModules`.
|
|
|
|
|
*/
|
|
|
|
|
const skipRenderChunk = (plugin, exclude) => {
|
|
|
|
|
if (!exclude) return plugin;
|
|
|
|
|
|
|
|
|
|
const { renderChunk } = plugin;
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
...plugin,
|
|
|
|
|
renderChunk(code, chunk, ...rest) {
|
|
|
|
|
if (exclude(chunk)) return null;
|
|
|
|
|
|
|
|
|
|
return renderChunk.call(this, code, chunk, ...rest);
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2025-11-27 10:50:19 +01:00
|
|
|
const plugins = ({
|
|
|
|
|
pkg,
|
|
|
|
|
minify = false,
|
|
|
|
|
withEsbuild = true,
|
|
|
|
|
esbuildOptions = {},
|
|
|
|
|
withSummary = false,
|
2026-11-12 12:20:16 +05:00
|
|
|
licenseBannerExclude,
|
2025-11-27 10:50:19 +01:00
|
|
|
}) =>
|
2020-12-02 13:48:39 +01:00
|
|
|
[
|
2024-03-06 21:03:12 +01:00
|
|
|
withEsbuild
|
|
|
|
|
? esbuild({
|
|
|
|
|
minify,
|
|
|
|
|
...esbuildOptions,
|
|
|
|
|
})
|
|
|
|
|
: null,
|
|
|
|
|
nodeResolve({
|
|
|
|
|
extensions: ['.js', '.ts', '.jsx', '.tsx'],
|
|
|
|
|
resolveOnly: [/^@lucide\/.*$/],
|
2020-12-02 13:48:39 +01:00
|
|
|
}),
|
2026-11-12 12:20:16 +05:00
|
|
|
skipRenderChunk(
|
|
|
|
|
license({
|
|
|
|
|
banner: `@license ${pkg.name} v${pkg.version} - ${pkg.license}
|
2023-11-17 11:12:31 +01:00
|
|
|
|
|
|
|
|
This source code is licensed under the ${pkg.license} license.
|
|
|
|
|
See the LICENSE file in the root directory of this source tree.`,
|
2026-11-12 12:20:16 +05:00
|
|
|
}),
|
|
|
|
|
licenseBannerExclude,
|
|
|
|
|
),
|
2025-11-27 10:50:19 +01:00
|
|
|
withSummary ? summary() : null,
|
2020-12-02 13:48:39 +01:00
|
|
|
visualizer({
|
|
|
|
|
sourcemap: true,
|
|
|
|
|
filename: `stats/${pkg.name}${minify ? '-min' : ''}.html`,
|
|
|
|
|
}),
|
|
|
|
|
].filter(Boolean);
|
|
|
|
|
|
2025-11-27 10:50:19 +01:00
|
|
|
export { license, visualizer, replace };
|
2023-01-17 08:04:34 +01:00
|
|
|
|
2021-03-23 19:26:50 +01:00
|
|
|
export default plugins;
|