This repository has been archived by the owner on Jan 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
105 lines (94 loc) · 3.67 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
96
97
98
99
100
101
102
103
104
105
/* eslint-disable no-undef */
import livereload from "rollup-plugin-livereload";
import { terser } from "rollup-plugin-terser";
import typescript from "@rollup/plugin-typescript";
import dev from "rollup-plugin-dev";
import html from "@rollup/plugin-html";
import * as fs from "fs";
import * as path from "path";
import * as rimraf from "rimraf";
const production = !process.env.ROLLUP_WATCH;
function serve() {
return dev({
dirs: ["./build"],
spa: "./index.html",
port: 8080,
});
}
rimraf.sync(path.join(__dirname, "build"));
fs.mkdirSync("build");
console.log("Production: ", production);
console.log("INTERNET_IDENTITY_URL", process.env.INTERNET_IDENTITY_URL);
console.log("NFID_URL", process.env.NFID_URL);
export default {
input: "./src/main.ts",
output: {
sourcemap: true,
format: "es",
name: "app",
dir: "build",
entryFileNames: "[name]-[hash].js",
},
plugins: [
typescript({
sourceMap: !production,
inlineSources: !production,
}),
// In dev mode, call `npm run start` once
// the bundle has been generated
!production && serve(),
// Watch the `public` directory and refresh the
// browser on changes when not in production
!production && livereload("public"),
// If we're building for production (npm run build
// instead of npm run dev), minify
production && terser(),
// nodePolyfills(/* options */),
html({
template: ({ files }) => {
const jsEntryFile = files.js.find((f) => f.isEntry).fileName;
return `
<!DOCTYPE html>
<html lang="en">
<head>
<title>OpenChat: Decentralized chat on the Internet Computer</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="description" content="OpenChat is a fully featured chat application running end-to-end on the Internet Computer blockchain." />
<script type="module" defer src="/${jsEntryFile}"></script>
<style>
body {
padding: 0;
margin: 0;
font-family: Helvetica;
}
.main {
display: flex;
justify-content: center;
align-items: center;
color: rgba(255, 255, 255, 0.8);
font-weight: 900;
background-color: #121212;
overflow-y: auto;
overflow-x: hidden;
height: 100vh;
min-height: 100%;
padding: 20px;
text-align: center;
}
</style>
</head>
<body>
<main class="main">
<h1>Please wait a moment while we load OpenChat ...</h1>
</main>
</body>
</html>
`;
},
}),
],
watch: {
clearScreen: false,
},
};