forked from windycom/windy-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
93 lines (84 loc) · 2.55 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
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',
},
};
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/**'],
exclude: 'node_modules/**',
clearScreen: false,
},
plugins: [
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: 'localhost',
port: 9999,
headers: {
'Access-Control-Allow-Origin': '*',
},
https: {
key: keyPEM,
cert: certificatePEM,
},
}),
],
};