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
|
|
|
|
2021-04-30 07:01:30 +00:00
|
|
|
// Directories
|
|
|
|
const rootDir = __dirname + '/';
|
|
|
|
const targetDir = 'dist';
|
|
|
|
const sourceDir = 'src';
|
|
|
|
const libDir = 'lib';
|
|
|
|
|
|
|
|
// Create dist
|
2020-08-22 12:31:44 +00:00
|
|
|
try {
|
2021-04-30 07:01:30 +00:00
|
|
|
fs.mkdirSync(rootDir + targetDir);
|
2020-08-22 12:31:44 +00:00
|
|
|
} catch (err) {}
|
2021-04-30 07:01:30 +00:00
|
|
|
|
|
|
|
// Copy Svelte files
|
2021-04-29 21:06:26 +00:00
|
|
|
['OfflineIcon.svelte'].forEach((file) => {
|
2020-08-22 12:31:44 +00:00
|
|
|
fs.writeFileSync(
|
2021-04-30 07:01:30 +00:00
|
|
|
rootDir + targetDir + '/' + file,
|
|
|
|
fs.readFileSync(rootDir + sourceDir + '/' + file)
|
2020-08-22 12:31:44 +00:00
|
|
|
);
|
2021-04-30 07:01:30 +00:00
|
|
|
console.log('copied (original)', file);
|
2020-08-22 12:31:44 +00:00
|
|
|
});
|
|
|
|
|
2021-04-30 07:01:30 +00:00
|
|
|
// Copy compiled files (should not include anything that isn't bundled below)
|
|
|
|
['offline.js'].forEach((file) => {
|
|
|
|
fs.writeFileSync(
|
|
|
|
rootDir + targetDir + '/' + file,
|
|
|
|
fs.readFileSync(rootDir + libDir + '/' + file)
|
|
|
|
);
|
|
|
|
console.log('copied (compiled)', file);
|
|
|
|
});
|
2021-04-29 16:02:28 +00:00
|
|
|
|
2020-08-22 12:31:44 +00:00
|
|
|
// Create bundle
|
|
|
|
export default [
|
|
|
|
// Bundle everything
|
|
|
|
{
|
2021-04-30 07:01:30 +00:00
|
|
|
input: sourceDir + '/offline.ts',
|
2020-08-22 12:31:44 +00:00
|
|
|
output: [
|
2021-04-30 07:01:30 +00:00
|
|
|
{ file: targetDir + '/offline-bundle.mjs', format: 'es' },
|
|
|
|
{ file: targetDir + '/offline-bundle.js', format: 'cjs' },
|
2020-08-22 12:31:44 +00:00
|
|
|
],
|
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-30 07:01:30 +00:00
|
|
|
// Files included in OfflineIcon.svelte as bundle
|
2020-08-22 12:31:44 +00:00
|
|
|
{
|
2021-04-30 07:01:30 +00:00
|
|
|
input: sourceDir + '/offline-functions.ts',
|
2020-08-22 12:31:44 +00:00
|
|
|
output: [
|
|
|
|
{
|
2021-04-30 07:01:30 +00:00
|
|
|
file: targetDir + '/offline-functions.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
|
|
|
},
|
|
|
|
];
|