-
Notifications
You must be signed in to change notification settings - Fork 35
/
vite.config.ts
58 lines (56 loc) · 1.74 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 { crx } from "@crxjs/vite-plugin";
import react from "@vitejs/plugin-react";
import { defineConfig, Plugin } from "vite";
import { viteStaticCopy } from "vite-plugin-static-copy";
import pkg from "./package.json";
// https://github.com/crxjs/chrome-extension-tools/issues/846#issuecomment-1861880919
const viteManifestHackIssue846: Plugin & { renderCrxManifest: (manifest: any, bundle: any) => void } = {
// Workaround from https://github.com/crxjs/chrome-extension-tools/issues/846#issuecomment-1861880919.
name: "manifestHackIssue846",
renderCrxManifest(_manifest, bundle) {
bundle["manifest.json"] = bundle[".vite/manifest.json"];
bundle["manifest.json"].fileName = "manifest.json";
delete bundle[".vite/manifest.json"];
},
};
export default defineConfig((env) => ({
resolve: {
alias: {
path: "path-browserify",
},
},
esbuild: {
drop: env.command === "build" ? ["console", "debugger"] : [],
},
plugins: [
viteManifestHackIssue846,
react(),
crx({
manifest: {
manifest_version: 3,
name: "Octohint",
version: pkg.version,
description: "IntelliSense hint for GitHub",
homepage_url: "https://github.com/pd4d10/octohint",
icons: {
"128": "icons/logo.png",
},
background: {
service_worker: "src/background.ts",
},
content_scripts: [
{
matches: [
"https://github.com/*",
"https://gist.github.com/*",
"https://gitlab.com/*",
"https://bitbucket.org/*",
],
js: ["src/content-script.tsx"],
},
],
},
}),
viteStaticCopy({ targets: [{ src: "../LICENSE", dest: "." }] }),
],
}));