1
0
mirror of https://github.com/tabler/tabler-icons.git synced 2025-08-31 09:32:04 +02:00

rollup config improvements

This commit is contained in:
codecalm
2024-02-28 01:14:57 +01:00
parent 203a5856a9
commit 2044b568a7
6 changed files with 54 additions and 171 deletions

View File

@@ -2,7 +2,7 @@ import { visualizer } from 'rollup-plugin-visualizer'
import license from 'rollup-plugin-license'
import esbuild from 'rollup-plugin-esbuild'
export const getRollupPlugins = (pkg, minify) => {
const getRollupPlugins = (pkg, minify) => {
return [
esbuild({
minify
@@ -19,3 +19,29 @@ See the LICENSE file in the root directory of this source tree.`
})
].filter(Boolean)
}
export const getRollupConfig = (pkg, outputFileName, bundles, globals) => {
return bundles
.map(({ inputs, format, minify, preserveModules, outputDir = 'dist', extension = 'js' }) =>
inputs.map(input => ({
input,
plugins: getRollupPlugins(pkg, minify),
external: Object.keys(globals),
output: {
name: pkg.name,
...(preserveModules
? {
dir: `${outputDir}/${format}`,
}
: {
file: `${outputDir}/${format}/${outputFileName}${minify ? '.min' : ''}.${extension}`,
}),
format,
sourcemap: true,
preserveModules,
globals,
},
})),
)
.flat();
}

View File

@@ -1,64 +1,33 @@
import fs from 'fs'
import { getRollupPlugins } from '../../.build/rollup-plugins.mjs'
import { getRollupConfig } from '../../.build/rollup-plugins.mjs'
import dts from "rollup-plugin-dts";
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf-8'))
const packageName = '@tabler/icons-preact';
const outputFileName = 'tabler-icons-preact';
const outputDir = 'dist';
const inputs = ['./src/tabler-icons-preact.ts'];
const bundles = [
{
format: 'umd',
inputs,
outputDir,
minify: true,
},
{
format: 'umd',
inputs,
outputDir,
},
{
format: 'cjs',
inputs,
outputDir,
},
{
format: 'esm',
inputs,
outputDir,
preserveModules: true,
extension: 'mjs',
},
];
const configs = bundles
.map(({ inputs, outputDir, format, minify, preserveModules }) =>
inputs.map(input => ({
input,
plugins: getRollupPlugins(pkg, minify),
external: ['preact'],
output: {
name: packageName,
...(preserveModules
? {
dir: `${outputDir}/${format}`,
}
: {
file: `${outputDir}/${format}/${outputFileName}${minify ? '.min' : ''}.js`,
}),
preserveModules,
format,
sourcemap: true,
globals: {
preact: 'preact'
},
},
})),
)
.flat();
export default [
{
input: inputs[0],
@@ -67,5 +36,7 @@ export default [
}],
plugins: [dts()],
},
...configs
...getRollupConfig(pkg, outputFileName, bundles, {
preact: 'preact'
})
];

View File

@@ -1,54 +1,24 @@
import fs from 'fs'
import { getRollupPlugins } from '../../.build/rollup-plugins.mjs'
import { getRollupConfig } from '../../.build/rollup-plugins.mjs'
import dts from "rollup-plugin-dts";
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf-8'))
const packageName = '@tabler/icons-react-native';
const outputFileName = 'tabler-icons-react-native';
const outputDir = 'dist';
const inputs = ['./src/tabler-icons-react-native.ts'];
const bundles = [
{
format: 'cjs',
inputs,
outputDir,
},
{
format: 'esm',
inputs,
outputDir,
preserveModules: true,
extension: 'mjs',
},
];
const configs = bundles
.map(({ inputs, outputDir, format, minify, preserveModules }) =>
inputs.map(input => ({
input,
plugins: getRollupPlugins(pkg, minify),
external: ['react', 'react-native-svg'],
output: {
name: packageName,
...(preserveModules
? {
dir: `${outputDir}/${format}`,
}
: {
file: `${outputDir}/${format}/${outputFileName}${minify ? '.min' : ''}.js`,
}),
format,
sourcemap: true,
preserveModules,
globals: {
react: 'react',
'react-native-svg': 'react-native-svg',
},
},
})),
)
.flat();
export default [
{
input: inputs[0],
@@ -57,5 +27,8 @@ export default [
}],
plugins: [dts()],
},
...configs
...getRollupConfig(pkg, outputFileName, bundles, {
react: 'react',
'react-native-svg': 'react-native-svg',
})
];

View File

@@ -1,64 +1,33 @@
import fs from 'fs'
import { getRollupPlugins } from '../../.build/rollup-plugins.mjs'
import { getRollupConfig } from '../../.build/rollup-plugins.mjs'
import dts from "rollup-plugin-dts";
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf-8'))
const packageName = '@tabler/icons-react';
const outputFileName = 'tabler-icons-react';
const outputDir = 'dist';
const inputs = ['./src/tabler-icons-react.ts'];
const bundles = [
{
format: 'umd',
inputs,
outputDir,
minify: true,
},
{
format: 'umd',
inputs,
outputDir,
},
{
format: 'cjs',
inputs,
outputDir,
},
{
format: 'esm',
inputs,
outputDir,
preserveModules: true,
extension: 'mjs',
},
];
const configs = bundles
.map(({ inputs, outputDir, format, minify, preserveModules }) =>
inputs.map(input => ({
input,
plugins: getRollupPlugins(pkg, minify),
external: ['react'],
output: {
name: packageName,
...(preserveModules
? {
dir: `${outputDir}/${format}`,
}
: {
file: `${outputDir}/${format}/${outputFileName}${minify ? '.min' : ''}.js`,
}),
format,
sourcemap: true,
preserveModules,
globals: {
react: 'react'
},
},
})),
)
.flat();
export default [
{
input: inputs[0],
@@ -67,5 +36,7 @@ export default [
}],
plugins: [dts()],
},
...configs
...getRollupConfig(pkg, outputFileName, bundles, {
react: 'react'
})
];

View File

@@ -1,65 +1,33 @@
import fs from 'fs'
import { getRollupPlugins } from '../../.build/rollup-plugins.mjs'
import { getRollupConfig } from '../../.build/rollup-plugins.mjs'
import dts from "rollup-plugin-dts";
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf-8'))
const packageName = '@tabler/icons-solidjs';
const outputFileName = 'tabler-icons-solidjs';
const outputDir = 'dist';
const inputs = ['./src/tabler-icons-solidjs.ts'];
const bundles = [
{
format: 'umd',
inputs,
outputDir,
minify: true,
},
{
format: 'umd',
inputs,
outputDir,
},
{
format: 'cjs',
inputs,
outputDir,
},
{
format: 'esm',
inputs,
outputDir,
preserveModules: true,
extension: 'mjs',
},
];
const configs = bundles
.map(({ inputs, outputDir, format, minify, preserveModules }) =>
inputs.map(input => ({
input,
plugins: getRollupPlugins(pkg, minify),
external: ['solid-js', 'solid-js/h'],
output: {
name: packageName,
...(preserveModules
? {
dir: `${outputDir}/${format}`,
}
: {
file: `${outputDir}/${format}/${outputFileName}${minify ? '.min' : ''}.js`,
}),
preserveModules,
format,
sourcemap: true,
globals: {
'solid-js': 'solid-js',
'solid-js/h': 'solid-js/h',
},
},
})),
)
.flat();
export default [
{
input: inputs[0],
@@ -68,5 +36,8 @@ export default [
}],
plugins: [dts()],
},
...configs
...getRollupConfig(pkg, outputFileName, bundles, {
'solid-js': 'solid-js',
'solid-js/h': 'solid-js/h',
})
];

View File

@@ -1,64 +1,33 @@
import fs from 'fs'
import { getRollupPlugins } from '../../.build/rollup-plugins.mjs'
import { getRollupConfig } from '../../.build/rollup-plugins.mjs'
import dts from "rollup-plugin-dts";
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf-8'))
const packageName = '@tabler/icons-vue';
const outputFileName = 'tabler-icons-vue';
const outputDir = 'dist';
const inputs = ['./src/tabler-icons-vue.ts'];
const bundles = [
{
format: 'umd',
inputs,
outputDir,
minify: true,
},
{
format: 'umd',
inputs,
outputDir,
},
{
format: 'cjs',
inputs,
outputDir,
},
{
format: 'esm',
inputs,
outputDir,
preserveModules: true,
extension: 'mjs',
},
];
const configs = bundles
.map(({ inputs, outputDir, format, minify, preserveModules }) =>
inputs.map(input => ({
input,
plugins: getRollupPlugins(pkg, minify),
external: ['vue'],
output: {
name: packageName,
...(preserveModules
? {
dir: `${outputDir}/${format}`,
}
: {
file: `${outputDir}/${format}/${outputFileName}${minify ? '.min' : ''}.js`,
}),
format,
preserveModules,
sourcemap: true,
globals: {
vue: 'vue',
},
},
})),
)
.flat();
export default [
{
input: inputs[0],
@@ -73,5 +42,7 @@ export default [
})
],
},
...configs
...getRollupConfig(pkg, outputFileName, bundles, {
vue: 'vue',
})
];