-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
55 lines (51 loc) · 1.41 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
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
import { UserConfig, defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import { resolve } from "path";
import * as fs from "fs";
const r = (rpath: string) => {
return resolve(__dirname, rpath);
};
// https://vitejs.dev/config/
export default defineConfig(() => {
let json: UserConfig = {};
json = {
build: {
emptyOutDir: false,
sourcemap: true,
reportCompressedSize: false,
target: "es2022",
minify: false,
cssMinify: false,
rollupOptions: {
input: {
content: r("./src/content/index.ts"),
},
output: {
format: "es",
entryFileNames: "[name].js",
},
},
},
plugins: [
{
name: "copyFiles",
enforce: "pre",
buildStart(options) {
["src/injectContentScript.js", "./manifest.json"].forEach((v) => {
this.addWatchFile(r(v));
});
if (!fs.existsSync(r("dist"))) fs.mkdirSync(r("dist"));
fs.copyFileSync(r("./src/injectContentScript.js"), r("dist/injectContentScript.js"));
fs.copyFileSync(r("./manifest.json"), r("dist/manifest.json"));
},
},
vue(),
],
};
return json;
});