-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathrollup.config.js
68 lines (63 loc) · 1.61 KB
/
rollup.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import typescript from '@rollup/plugin-typescript';
import svelte from 'rollup-plugin-svelte';
import resolve from '@rollup/plugin-node-resolve';
import sveltePreprocess from 'svelte-preprocess';
import commonjs from '@rollup/plugin-commonjs';
import metablock from 'rollup-plugin-userscript-metablock';
import fs from 'fs';
import terser from '@rollup/plugin-terser';
import makeBookmarklet from './makeBookmarket.js';
const pkg = JSON.parse(fs.readFileSync('./package.json'));
const full = process.argv.includes('full');
let output = [
{
file: 'build/bundle.js',
format: 'iife'
}
]
let otherOutputs = [
{
file: 'build/bundle.user.js',
format: 'iife',
plugins: [
metablock({
file: './meta.json',
override: {
version: pkg.version
}
})
]
},
{
file: 'build/bundle.bookmarklet.txt',
format: 'iife',
plugins: [
terser(),
makeBookmarklet()
]
}
];
// If we're doing a full build, also create a userscript and bookmarklet
if (full) {
output = output.concat(otherOutputs);
}
export default {
input: 'src/main.ts',
output,
plugins: [
typescript(),
commonjs(),
svelte({
emitCss: false,
compilerOptions: {
css: 'injected'
},
preprocess: sveltePreprocess()
}),
resolve({
browser: true,
exportConditions: ['svelte'],
extensions: ['.svelte', '.js', '.ts', '.json']
})
]
}