forked from pt-plugins/PT-Plugin-Plus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.background.ts
48 lines (46 loc) · 1.32 KB
/
vite.config.background.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 path from 'node:path'
import {defineConfig} from 'vite'
import {sharedConfig} from "./vite.config";
import fs from "node:fs";
import git from 'git-rev-sync'
import {nodePolyfills} from 'vite-plugin-node-polyfills'
import buildResource from "./vite/buildResource";
// https://vitejs.dev/config/
export default defineConfig({
...sharedConfig,
build: {
minify: false,
outDir: path.resolve(__dirname, 'dist/background'),
lib: {
entry: path.resolve(__dirname, 'src/background/index.ts'),
name: 'background',
formats: ['iife']
},
rollupOptions: {
treeshake: false,
output: {
entryFileNames: 'index.js',
extend: true,
},
},
chunkSizeWarningLimit: Number.MAX_SAFE_INTEGER,
emptyOutDir: false,
copyPublicDir: false
},
plugins: [
nodePolyfills({
include: ['path'],
}),
buildResource(),
{
name: 'update_manifest_version',
closeBundle() {
const manifest_file_path = path.resolve(__dirname, './dist/manifest.json');
const manifest = JSON.parse(fs.readFileSync(manifest_file_path, 'utf-8'));
const build_number = git.count() % 65535;
manifest.version = `${manifest.version}.${build_number}`;
fs.writeFileSync(manifest_file_path, JSON.stringify(manifest, null, 2));
},
}
]
})