2
0
mirror of https://github.com/iconify/iconify.git synced 2024-11-10 15:20:54 +00:00
iconify/packages/svelte/rollup.config.js

69 lines
1.4 KiB
JavaScript
Raw Normal View History

import fs from 'fs';
import svelte from 'rollup-plugin-svelte';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
2021-04-29 18:06:25 +00:00
import typescript from '@rollup/plugin-typescript';
import sveltePreprocess from 'svelte-preprocess';
import pkg from './package.json';
// Copy Icon.svelte
try {
fs.mkdirSync(__dirname + '/dist');
} catch (err) {}
['OfflineIcon.svelte'].forEach((file) => {
fs.writeFileSync(
__dirname + '/dist/' + file,
fs.readFileSync(__dirname + '/src/' + file)
);
});
// Create component.mjs
fs.writeFileSync(
__dirname + '/dist/component.mjs',
2021-04-29 18:06:25 +00:00
fs.readFileSync(__dirname + '/src/index.ts')
);
// Create bundle
const name = pkg.name
.replace(/^(@\S+\/)?(svelte-)?(\S+)/, '$3')
.replace(/^\w/, (m) => m.toUpperCase())
.replace(/-\w/g, (m) => m[1].toUpperCase());
export default [
// Bundle everything
{
2021-04-29 18:06:25 +00:00
input: 'src/index.ts',
output: [
{ file: pkg.module, format: 'es' },
{ file: pkg.main, format: 'umd', name },
],
2021-04-29 18:06:25 +00:00
plugins: [
svelte({
preprocess: sveltePreprocess(),
}),
resolve({
extensions: ['.ts', '.js', '.svelte'],
}),
typescript(),
commonjs(),
],
},
// Files included in OfflineIcon.svelte as bundles without dependencies
{
input: 'src/offline.ts',
output: [
{
file: 'dist/offline.js',
format: 'es',
},
],
2021-04-29 18:06:25 +00:00
plugins: [
resolve({
extensions: ['.ts', '.js', '.svelte'],
}),
typescript(),
commonjs(),
],
},
];