2020-08-22 12:31:44 +00:00
|
|
|
import fs from 'fs';
|
2020-04-28 19:40:05 +00:00
|
|
|
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';
|
2020-04-28 19:40:05 +00:00
|
|
|
import pkg from './package.json';
|
|
|
|
|
2020-08-22 12:31:44 +00:00
|
|
|
// Copy Icon.svelte
|
|
|
|
try {
|
|
|
|
fs.mkdirSync(__dirname + '/dist');
|
|
|
|
} catch (err) {}
|
2021-04-29 21:06:26 +00:00
|
|
|
['OfflineIcon.svelte'].forEach((file) => {
|
2020-08-22 12:31:44 +00:00
|
|
|
fs.writeFileSync(
|
|
|
|
__dirname + '/dist/' + file,
|
|
|
|
fs.readFileSync(__dirname + '/src/' + file)
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2021-04-29 16:02:28 +00:00
|
|
|
// Create component.mjs
|
|
|
|
fs.writeFileSync(
|
|
|
|
__dirname + '/dist/component.mjs',
|
2021-04-29 18:06:25 +00:00
|
|
|
fs.readFileSync(__dirname + '/src/index.ts')
|
2021-04-29 16:02:28 +00:00
|
|
|
);
|
|
|
|
|
2020-08-22 12:31:44 +00:00
|
|
|
// Create bundle
|
2020-04-28 19:40:05 +00:00
|
|
|
const name = pkg.name
|
|
|
|
.replace(/^(@\S+\/)?(svelte-)?(\S+)/, '$3')
|
|
|
|
.replace(/^\w/, (m) => m.toUpperCase())
|
|
|
|
.replace(/-\w/g, (m) => m[1].toUpperCase());
|
|
|
|
|
2020-08-22 12:31:44 +00:00
|
|
|
export default [
|
|
|
|
// Bundle everything
|
|
|
|
{
|
2021-04-29 18:06:25 +00:00
|
|
|
input: 'src/index.ts',
|
2020-08-22 12:31:44 +00:00
|
|
|
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(),
|
|
|
|
],
|
2020-08-22 12:31:44 +00:00
|
|
|
},
|
2021-04-29 21:06:26 +00:00
|
|
|
// Files included in OfflineIcon.svelte as bundles without dependencies
|
2020-08-22 12:31:44 +00:00
|
|
|
{
|
2021-04-29 21:06:26 +00:00
|
|
|
input: 'src/offline.ts',
|
2020-08-22 12:31:44 +00:00
|
|
|
output: [
|
|
|
|
{
|
2021-04-29 21:06:26 +00:00
|
|
|
file: 'dist/offline.js',
|
2020-08-22 12:31:44 +00:00
|
|
|
format: 'es',
|
|
|
|
},
|
|
|
|
],
|
2021-04-29 18:06:25 +00:00
|
|
|
plugins: [
|
|
|
|
resolve({
|
|
|
|
extensions: ['.ts', '.js', '.svelte'],
|
|
|
|
}),
|
|
|
|
typescript(),
|
|
|
|
commonjs(),
|
|
|
|
],
|
2020-08-22 12:31:44 +00:00
|
|
|
},
|
|
|
|
];
|