1
0
mirror of https://github.com/tabler/tabler-icons.git synced 2025-01-17 04:38:28 +01:00
tabler-icons/.build/rollup-plugins.mjs
Paweł Kuna ceed535efb
Import fixes (#1039)
* fix packages imports

* imports check scripts

* update packages

* svelte build improvements

* build fix
2024-03-12 12:19:23 +01:00

51 lines
1.4 KiB
JavaScript

import { visualizer } from 'rollup-plugin-visualizer'
import license from 'rollup-plugin-license'
import esbuild from 'rollup-plugin-esbuild'
const getRollupPlugins = (pkg, minify) => {
return [
esbuild({
minify
}),
license({
banner: `@license ${pkg.name} v${pkg.version} - ${pkg.license}
This source code is licensed under the ${pkg.license} license.
See the LICENSE file in the root directory of this source tree.`
}),
visualizer({
sourcemap: false,
filename: `stats/${pkg.name}${minify ? '-min' : ''}.html`
})
].filter(Boolean)
}
export const getRollupConfig = (pkg, outputFileName, bundles, globals) => {
return bundles
.map(({ inputs, format, minify, preserveModules, outputDir = 'dist', extension = 'js', exports = 'named' }) => {
return inputs.map(input => ({
input,
plugins: getRollupPlugins(pkg, minify),
external: Object.keys(globals),
output: {
name: pkg.name,
...(preserveModules
? {
dir: `${outputDir}/${format}`,
entryFileNames: `[name].${extension}`,
}
: {
file: `${outputDir}/${format}/${outputFileName}${minify ? '.min' : ''}.${extension}`,
}),
format,
sourcemap: true,
preserveModules,
preserveModulesRoot: 'src',
exports,
globals,
},
}))
})
.flat();
}