forked from word-hunter/word-hunter
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvite.config.ts
48 lines (43 loc) · 1.22 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
import fs from 'node:fs'
import path from 'node:path'
import { defineConfig } from 'vite'
import solidPlugin from 'vite-plugin-solid'
import { crx, ManifestV3Export } from '@crxjs/vite-plugin'
import manifest from './manifest.json'
/**
* @HACK: Chrome 128 implements the use_dynamic_url feature. If it's set to true, chrome will not load
* the content js file, and crx always set this field to true.
*/
function updateManifest() {
const manifestPath = path.relative(__dirname, './build/manifest.json')
const json = JSON.parse(fs.readFileSync(manifestPath, 'utf8'))
if (json) {
json.web_accessible_resources.forEach((resource: any) => {
resource.use_dynamic_url = false
})
fs.writeFileSync(manifestPath, JSON.stringify(json, null, 2))
}
}
function updateManifestPlugin() {
return {
name: 'update-manifest',
transform: updateManifest,
writeBundle: updateManifest
}
}
export default defineConfig({
build: {
outDir: 'build',
target: 'esnext',
rollupOptions: {
input: {
review: 'src/review.html'
}
},
sourcemap: false
},
server: {
cors: false
},
plugins: [solidPlugin(), crx({ manifest: manifest as ManifestV3Export }), updateManifestPlugin()]
})