-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
58 lines (53 loc) · 1.88 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
// Rollup config for production
//
import svelte from 'rollup-plugin-svelte';
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import { terser } from 'rollup-plugin-terser';
import pkg from './package.json';
const input = 'src/index.svelte';
const production = !process.env.ROLLUP_WATCH;
// Note: Normally, Rollup suggest providing multiple targets with same input (as we have) as an 'output' array,
// but that doesn't allow for different 'external' and (input) 'plugins' fields. This seems safer. AK/24-Nov-19
export default [
// ES6 + ES modules (future ready) -> https://caniuse.com/#feat=es6-module
{
input,
output: { file: pkg.module, format: 'es', sourcemap: true },
external: ['svelte/internal'],
plugins: [
svelte({ dev: !production }), // enable runtime checks
production && terser() // minify
]
},
// ES5 + UMD (modern day) - only IE 6..11 would need this
{
input,
output: { file: pkg.main, format: 'umd', name: 'Demo' },
plugins: [
svelte(),
resolve()
]
},
// Demo app / test bench
{
input: "app/index.js",
output: {
file: "app/public/bundle.js",
format: "iife", // Q: is 'iife' a good target? #advice
sourcemap: true
},
plugins: [
svelte({ dev: true, css: css => css.write('app/public/bundle.css') }),
resolve({
jsnext: true, // tbd. why? (from svelte-spinner example) #advice
main: true, // tbd. why? (-''-) #advice
browser: true // tbd. why? (-''-) #advice
}),
commonjs() // tbd. is this neeeded and why?
],
watch: {
clearScreen: false
}
}
];