forked from ekcom/TkAst
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
53 lines (50 loc) · 1.72 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
import { defineConfig } from "vite";
import path from "path";
const rootDir = path.resolve(__dirname, "src");
const pagesDir = path.resolve(rootDir, "pages");
const assetsDir = path.resolve(__dirname, "src/static");
const outDir = path.resolve(__dirname, "build");
export default defineConfig({
resolve: {
alias: {
//"@src": rootDir,
//"@assets": assetsDir,
"utils": path.resolve(rootDir, "utils"),
"config": path.resolve(rootDir, "config"),
},
},
root: rootDir,
publicDir: assetsDir,
build: {
target: "ES2015",
outDir,
emptyOutDir: true,
copyPublicDir: true,
sourcemap: process.env.NODE_ENV === "development",
minify: process.env.NODE_ENV === "development" ? false : "esbuild",
rollupOptions: {
input: {
// pages
index: path.join(pagesDir, "/index.html"),
options: path.join(pagesDir, "/options.html"),
trouble: path.join(pagesDir, "/trouble.html"), // help page
// service worker
serviceWorker: path.join(rootDir, "/serviceWorker.ts"),
// content scripts
// built in buildContentScripts.ts in iife
},
output: {
entryFileNames: "scripts/[name].js",
chunkFileNames: "scripts/[name]-[hash].js",
format: "es", // uses `import`
},
},
},
test: {
// specify repo root for testing
// so it knows where to store its metadata in node_modules
// todo: this won't work
// because it confuses the absolute path aliases
//root: __dirname,
},
});