forked from mxx1111/mdlook
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwxt.config.ts
More file actions
104 lines (100 loc) · 2.51 KB
/
Copy pathwxt.config.ts
File metadata and controls
104 lines (100 loc) · 2.51 KB
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
import type { ConfigEnv } from 'vite'
import fs from 'node:fs'
import path from 'node:path'
import { defineConfig } from 'wxt'
import ViteConfig from './vite.config'
function getRootPackageVersion() {
let dir = __dirname
while (dir !== path.parse(dir).root) {
const pkgPath = path.join(dir, `package.json`)
if (fs.existsSync(pkgPath)) {
const pkg = JSON.parse(fs.readFileSync(pkgPath, `utf-8`))
if (pkg.version)
return pkg.version
}
dir = path.dirname(dir)
}
return `0.0.0`
}
const version = getRootPackageVersion()
export default defineConfig({
srcDir: `src`,
modulesDir: `src/modules`,
manifest: ({ browser }) => ({
name: `mdlook · 公众号排版`,
version,
icons: {
256: `/favicon.png`,
},
permissions: [`storage`, `activeTab`, `sidePanel`, `contextMenus`],
host_permissions: [
`https://*.github.com/*`,
`https://*.githubusercontent.com/*`,
`https://*.gitee.com/*`,
`https://*.weixin.qq.com/*`,
// 微信公众号图片
`https://*.qpic.cn/*`,
`https://www.plantuml.com/*`,
],
web_accessible_resources: [
{
resources: [`*.png`, `*.svg`, `injected.js`],
matches: [`<all_urls>`],
},
],
side_panel: browser === `chrome`
? {
default_path: `sidepanel.html`,
}
: undefined,
sidebar_action: browser === `firefox`
? {
default_panel: `sidepanel.html`,
default_icon: {
256: `favicon.png`,
},
default_title: `mdlook · 公众号排版`,
}
: undefined,
commands: {
_execute_sidebar_action: {
description: `打开 mdlook 公众号排版侧边栏`,
suggested_key: {
default: `Ctrl+Shift+Y`,
},
},
},
}),
zip: {
name: `mdlook`,
artifactTemplate: `{{name}}-{{version}}-{{browser}}.zip`,
excludeSources: [
`dist/**`,
`docker/**`,
`docs/**`,
`example/**`,
`functions/**`,
`md-cli/**`,
`scripts/**`,
`src/extension/**`,
],
},
analysis: {
open: true,
},
vite: ({ mode }) => {
const config = ViteConfig({ mode } as ConfigEnv)
return {
...config,
plugins: config.plugins!.filter((plugin) => {
if (typeof plugin === `object` && plugin != null && `name` in plugin && plugin?.name === `vite-plugin-Radar`) {
return false
}
return true
}),
define: undefined,
build: undefined,
base: `/`,
}
},
})