forked from windycom/windy-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
125 lines (116 loc) · 3.46 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import typescript from '@rollup/plugin-typescript';
import terser from '@rollup/plugin-terser';
import serve from 'rollup-plugin-serve';
import rollupSvelte from 'rollup-plugin-svelte';
import rollupSwc from 'rollup-plugin-swc3';
import rollupCleanup from 'rollup-plugin-cleanup';
import { less } from 'svelte-preprocess-less';
import sveltePreprocess from 'svelte-preprocess';
import { transformCodeToESMPlugin, keyPEM, certificatePEM } from '@windycom/plugin-devtools';
const useSourceMaps = true;
const buildConfigurations = {
src: {
input: 'src/plugin.svelte',
out: 'plugin',
},
example01: {
input: 'examples/01-hello-world/plugin.svelte',
out: 'example01/plugin',
},
example02: {
input: 'examples/02-using-vanilla-js/plugin.svelte',
out: 'example02/plugin',
},
example03: {
input: 'examples/03-boat-tracker/plugin.svelte',
out: 'example03/plugin',
},
example04: {
input: 'examples/04-aircraft-range/plugin.svelte',
out: 'example04/plugin',
},
example05: {
input: 'examples/05-airspace-map/plugin.svelte',
out: 'example05/plugin',
},
example06: {
input: 'examples/06-foehn-chart/plugin.svelte',
out: 'example06/plugin',
},
example07: {
input: 'examples/07-meteoblue-meteograms/plugin.svelte',
out: 'example07/plugin',
},
};
const requiredConfig = process.env.CONFIG || 'src';
const { input, out } = buildConfigurations[requiredConfig];
export default {
input,
output: [
{
file: `dist/${out}.js`,
format: 'module',
sourcemap: true,
},
{
file: `dist/${out}.min.js`,
format: 'module',
plugins: [rollupCleanup({ comments: 'none', extensions: ['ts'] }), terser()],
},
],
onwarn: () => {
/* We disable all warning messages */
},
external: id => id.startsWith('@windy/'),
watch: {
include: ['src/**', 'examples/**'],
exclude: 'node_modules/**',
clearScreen: false,
},
plugins: [
typescript({
sourceMap: useSourceMaps,
inlineSources: false,
}),
rollupSwc({
include: ['**/*.ts', '**/*.svelte'],
sourceMaps: useSourceMaps,
}),
rollupSvelte({
emitCss: false,
preprocess: {
style: less({
sourceMap: false,
math: 'always',
}),
script: data => {
const preprocessed = sveltePreprocess({ sourceMap: useSourceMaps });
return preprocessed.script(data);
},
},
}),
resolve({
browser: true,
mainFields: ['module', 'jsnext:main', 'main'],
preferBuiltins: false,
dedupe: ['svelte'],
}),
commonjs(),
transformCodeToESMPlugin(),
process.env.SERVE !== 'false' &&
serve({
contentBase: 'dist',
host: '0.0.0.0',
port: 9999,
headers: {
'Access-Control-Allow-Origin': '*',
},
https: {
key: keyPEM,
cert: certificatePEM,
},
}),
],
};