-
Notifications
You must be signed in to change notification settings - Fork 2
/
rollup.config.mjs
82 lines (77 loc) · 2.72 KB
/
rollup.config.mjs
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
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 sveltePreprocess from "svelte-preprocess";
import typescript from "@rollup/plugin-typescript";
import json from "@rollup/plugin-json";
import { svelteSVG } from 'rollup-plugin-svelte-svg';
import builtins from 'rollup-plugin-node-builtins';
import path from 'path';
import fs from 'fs';
import css from 'rollup-plugin-css-only';
import {fileURLToPath} from 'url';
import tailwindcss from "tailwindcss";
import autoprefixer from "autoprefixer";
const production = !process.env.ROLLUP_WATCH;
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
export default fs
.readdirSync(path.join(__dirname, "webviews", "pages"))
.map((input) => {
const name = input.split(".")[0];
return {
input: "webviews/pages/" + input,
output: {
sourcemap: !production,
format: "iife",
name: "app",
file: "out/compiled/" + name + ".js",
assetFileNames: name + '.css',
},
onwarn: function (message) {
if (message.code !== 'EVAL'){
console.log(JSON.stringify(message));
throw new Error(message);
}
},
plugins: [
svelte({
compilerOptions: {
// enable run-time checks when not in production
dev: !production,
},
preprocess: sveltePreprocess({
sourceMap: !production,
postcss: {
plugins: [tailwindcss, autoprefixer],
},
}),
emitCss: production,
}),
css(),
json(),
resolve({
browser: true,
dedupe: ["svelte"],
preferBuiltins: false
}),
commonjs(),
builtins(),
svelteSVG({
// optional SVGO options
// pass empty object to enable defaults
svgo: {},
}),
production && terser(),
typescript({
tsconfig: "webviews/tsconfig.json",
sourceMap: !production,
inlineSources: !production,
}),
],
watch: {
clearScreen: false,
},
};
});