-
Notifications
You must be signed in to change notification settings - Fork 236
/
Copy pathbuild-ext-demo.js
42 lines (37 loc) · 1006 Bytes
/
build-ext-demo.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
/**
* @file Build extension pages demonstration using the Vite JavaScript API
* @see {@link https://vitejs.dev/guide/api-javascript.html JavaScript API}
*/
import { build } from "vite";
import { svelte } from "@sveltejs/vite-plugin-svelte";
import * as Utils from "./utils.js";
/** @type {import("vite").InlineConfig} */
const sharedConfig = {
...Utils.baseConfig,
mode: "development",
define: {
...Utils.baseConfig.define,
"import.meta.env.SAFARI_VERSION": JSON.stringify(15),
"import.meta.env.EXT_DEMO_BUILD": JSON.stringify(true),
},
};
/**
* Empty resources directory
* Copy public static assets
*/
await Utils.emptyBuildDir("dist");
Utils.cp("public/ext/shared", "dist");
/** Build shared modules */
build({
...sharedConfig,
plugins: [svelte()],
publicDir: "public/ext/vendor/",
build: {
outDir: `dist/`,
emptyOutDir: false,
rollupOptions: {
input: ["entry-ext-action-popup.html", "entry-ext-extension-page.html"],
},
target: "esnext", // top-level await
},
});