forked from andreasbm/router-slot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.ts
92 lines (87 loc) · 1.56 KB
/
rollup.config.ts
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
import path from "path";
import pkg from "./package.json";
import {
defaultExternals,
defaultOutputConfig,
defaultPlugins,
defaultProdPlugins,
defaultServePlugins,
isLibrary,
isProd,
isServe
} from "@appnest/web-config";
const folders = {
dist: path.resolve(__dirname, "dist"),
src: path.resolve(__dirname, "src/demo")
};
const files = {
main: path.join(folders.src, "app.ts"),
src_index: path.join(folders.src, "index.html"),
dist_index: path.join(folders.dist, "index.html")
};
export default {
input: {
main: files.main
},
output: [
defaultOutputConfig({
format: "esm",
dir: folders.dist
})
],
plugins: [
...defaultPlugins({
cleanConfig: {
targets: [
folders.dist
]
},
htmlTemplateConfig: {
template: files.src_index,
target: files.dist_index,
include: /main(-.*)?\.js$/
}
}),
// Serve
...(isServe ? [
...defaultServePlugins({
serveConfig: {
port: 1338,
contentBase: folders.dist
},
livereloadConfig: {
watch: folders.dist
}
})
] : []),
// Production
...(isProd ? [
...defaultProdPlugins({
dist: folders.dist,
minifyLitHtmlConfig: {
verbose: false
},
visualizerConfig: {
filename: path.join(folders.dist, "stats.html")
},
licenseConfig: {
thirdParty: {
output: path.join(folders.dist, "licenses.txt")
}
},
budgetConfig: {
sizes: {
".js": 1024 * 200
}
}
})
] : [])
],
external: [
...(isLibrary ? [
...defaultExternals(pkg)
] : [])
],
treeshake: isProd,
context: "window"
}