-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathvite.config.ts
58 lines (56 loc) · 1.51 KB
/
vite.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
import { resolve } from "node:path";
import { svelte } from "@sveltejs/vite-plugin-svelte";
import * as devCerts from "office-addin-dev-certs";
import { defineConfig } from "vite";
import { createHtmlPlugin } from "vite-plugin-html";
async function getHttpsOptions() {
const httpsOptions = await devCerts.getHttpsServerOptions();
return {
ca: httpsOptions.ca,
key: httpsOptions.key,
cert: httpsOptions.cert,
};
}
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
svelte(),
createHtmlPlugin({
minify: true,
pages: [
{
entry: "src/main.ts",
filename: "index.html", // updated this to index.html now we serve the taskpane.html from https:localhost:3000/
template: "taskpane.html",
injectOptions: {
data: {
injectScript: `<script src="./main.js"></script>`,
},
},
},
{
entry: "src/commands.ts",
filename: "commands.html",
template: "commands.html",
injectOptions: {
data: {
injectScript: `<script src="./commands.js"></script>`,
},
},
},
],
}),
],
server: {
https: await getHttpsOptions(),
port: Number.parseInt(process.env.server_port) || 3000,
strictPort: false,
open: "/", // opens the correct /taskpane.html when opening browser to view in web
},
preview: {
https: await getHttpsOptions(),
port: Number.parseInt(process.env.preview_server_port) || 3000,
strictPort: false,
open: "/taskpane.html", // opens the correct /taskpane.html when opening browser to view in web
},
});