-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathrollup.config.mjs
64 lines (60 loc) · 1.51 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
import { rimraf } from "rimraf";
import postcss from "rollup-plugin-postcss";
import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import esbuild from "rollup-plugin-esbuild";
import svelte from "rollup-plugin-svelte";
import sveltePreprocess from "svelte-preprocess";
import glob from "fast-glob";
const paths = {
src: "src/main/javascript",
dist: "target/classes/static/assets",
};
export default {
input: {
"custom-elements-polyfill": `@ungap/custom-elements`,
...inputFiles(),
},
output: {
dir: paths.dist,
format: "es",
sourcemap: true,
manualChunks: {
"duet-date-picker": [
"@duetds/date-picker",
"@duetds/date-picker/custom-element",
],
"date-fns": ["date-fns"],
},
},
plugins: [
{
name: "clean",
buildStart() {
rimraf.sync(paths.dist);
},
},
svelte({
include: `${paths.src}/**/*.svelte`,
preprocess: sveltePreprocess(),
}),
postcss(),
resolve({
preferBuiltins: false,
browser: true,
}),
commonjs(),
esbuild({
sourceMap: true,
minify: process.env.NODE_ENV === "production",
}),
],
};
function inputFiles() {
const files = glob.sync(`${paths.src}/bundles/*.ts`);
return Object.fromEntries(files.map((file) => [entryName(file), file]));
}
function entryName(file) {
const filename = file.slice(Math.max(0, file.lastIndexOf("/") + 1));
return filename.slice(0, Math.max(0, filename.lastIndexOf(".")));
}