-
Notifications
You must be signed in to change notification settings - Fork 1
/
rollup.config.js
77 lines (59 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import commonjsPlugin from '@rollup/plugin-commonjs';
import cssPlugin from 'rollup-plugin-css-only';
import dotenvPlugin from 'rollup-plugin-dotenv';
import livereloadPlugin from 'rollup-plugin-livereload';
import resolvePlugin from '@rollup/plugin-node-resolve';
import sveltePlugin from 'rollup-plugin-svelte';
import sveltePreprocess from 'svelte-preprocess';
import typescriptPlugin from '@rollup/plugin-typescript';
import { terser as terserPlugin } from 'rollup-plugin-terser';
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
const ENV = process.env.NODE_ENV;
const IS_DEV = ENV === 'development';
const LIVE_RELOAD = !process.env.LIVE_RELOAD
? IS_DEV
: ['true', '1'].includes(process.env.LIVE_RELOAD);
export default {
input: 'src/main.ts',
onwarn: function(warning, warn) {
const { code, loc } = warning;
// Squelch "`this` has been rewritten to `undefined`" warning
// originating in OpenLayers.
if (code === 'THIS_IS_UNDEFINED' && loc.file.match(/node_modules[/]ol[/].+?[.]js$/)) {
return;
}
return warn(warning);
},
output: {
sourcemap: true,
format: 'iife',
name: 'app',
file: 'public/build/bundle.js'
},
watch: {
clearScreen: false
},
plugins: [
dotenvPlugin(),
sveltePlugin({
preprocess: sveltePreprocess({
sourceMap: IS_DEV
}),
compilerOptions: {
dev: IS_DEV
}
}),
cssPlugin({ output: 'bundle.css' }),
resolvePlugin({
browser: true,
dedupe: ['svelte']
}),
commonjsPlugin(),
typescriptPlugin({
sourceMap: IS_DEV,
inlineSources: IS_DEV
}),
LIVE_RELOAD && livereloadPlugin('public'),
!IS_DEV && terserPlugin()
]
};