-
Notifications
You must be signed in to change notification settings - Fork 10
/
rollup.config.js
95 lines (90 loc) · 1.61 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
import {
defaultExternals,
defaultOutputConfig,
defaultPlugins,
defaultProdPlugins,
defaultServePlugins,
isLibrary,
isProd,
isServe
} from "@appnest/web-config";
import path from "path";
import pkg from "./package.json";
const folders = {
src: path.resolve(__dirname, "src/demo"),
dist: path.resolve(__dirname, "dist")
};
const files = {
main: path.join(folders.src, "main.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({
cleanerConfig: {
targets: [
folders.dist
]
},
copyConfig: {
resources: [
],
},
htmlTemplateConfig: {
template: files.src_index,
target: files.dist_index,
include: /main(-.*)?\.js$/
},
importStylesConfig: {
globals: ["global.scss"]
}
}),
// Serve
...(isServe ? [
...defaultServePlugins({
serveConfig: {
port: 1341,
contentBase: folders.dist
},
livereloadConfig: {
watch: folders.dist,
port: 35731
}
})
] : []),
// 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")
}
}
})
] : [])
],
external: [
...(isLibrary ? [
...defaultExternals(pkg)
] : [])
],
treeshake: isProd,
context: "window"
}