-
Notifications
You must be signed in to change notification settings - Fork 24
/
manifest.ts
67 lines (62 loc) · 1.86 KB
/
manifest.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
59
60
61
62
63
64
65
66
67
import fs from 'fs-extra'
import type { Manifest } from 'webextension-polyfill'
import type PkgType from '../package.json'
import { isDev, port, r } from '../scripts/utils'
export async function getManifest() {
const pkg = await fs.readJSON(r('package.json')) as typeof PkgType
// update this file to update this manifest.json
// can also be conditional based on your need
// @ts-ignore
// @ts-ignore
const manifest: Manifest.WebExtensionManifest = {
manifest_version: 2,
name: pkg.displayName || pkg.name,
version: pkg.version,
description: pkg.description,
browser_action: {
default_icon: './assets/icon-512.png',
default_popup: './dist/popup/index.html',
},
background: {
page: './dist/background/index.html',
persistent: false,
},
commands: {
// @ts-ignore
'run-search': {
suggested_key: {
default: 'Alt+F',
mac: 'Alt+F',
},
description: 'Run history search',
},
},
icons: {
16: './assets/icon-512.png',
48: './assets/icon-512.png',
128: './assets/icon-512.png',
},
permissions: [
'http://*/',
'https://*/',
'history',
],
content_scripts: [{
matches: ['http://*/*', 'https://*/*'],
js: ['./dist/contentScripts/index.global.js'],
}],
web_accessible_resources: [
'dist/contentScripts/style.css',
],
}
if (isDev) {
// for content script, as browsers will cache them for each reload,
// we use a background script to always inject the latest version
// see src/background/contentScriptHMR.ts
delete manifest.content_scripts
manifest.permissions?.push('webNavigation')
// this is required on dev for Vite script to load
manifest.content_security_policy = `script-src \'self\' http://localhost:${port}; object-src \'self\'`
}
return manifest
}