-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathvite.config.base.ts
More file actions
81 lines (76 loc) · 2.36 KB
/
vite.config.base.ts
File metadata and controls
81 lines (76 loc) · 2.36 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
import { resolve } from "path";
import { ManifestV3Export } from "@crxjs/vite-plugin";
import tailwindcss from "@tailwindcss/vite";
import { defineConfig, BuildOptions, build } from "vite";
import tsconfigPaths from "vite-tsconfig-paths";
import { stripDevIcons, crxI18n } from "./custom-vite-plugins";
import manifest from "./manifest.json";
import devManifest from "./manifest.dev.json";
import pkg from "./package.json";
const isDev = process.env.__DEV__ === "true";
// set this flag to true, if you want localization support
const localize = false;
export const baseManifest = {
...manifest,
version: pkg.version,
...(isDev ? devManifest : ({} as ManifestV3Export)),
...(localize
? {
name: "__MSG_extName__",
description: "__MSG_extDescription__",
default_locale: "en",
}
: {}),
} as ManifestV3Export;
export const baseBuildOptions: BuildOptions = {
sourcemap: isDev,
emptyOutDir: !isDev,
};
export default defineConfig({
plugins: [
//
tailwindcss(),
tsconfigPaths(),
stripDevIcons(isDev),
crxI18n({ localize, src: "./src/locales" }),
],
publicDir: resolve(__dirname, "public"),
build: {
minify: false,
rollupOptions: {
input: {
devtoolsPanel: resolve(__dirname, "src/pages/devtools/panel.html"),
},
},
// rollupOptions: {
// external: ["/ts.bundle.js"],
// },
},
});
export function bundleInPageScriptPlugin(outDir: string) {
return {
name: "bundle-inpage-as-single-file",
async closeBundle() {
// Build the InPage IIFE
await build({
configFile: false,
build: {
outDir,
emptyOutDir: false, // don’t wipe CRX build
lib: {
entry: "src/pages/inpage/inpage-index.ts",
name: "Inpage",
fileName: "inpage",
formats: ["iife"],
},
rollupOptions: {
output: {
inlineDynamicImports: true,
entryFileNames: "inpage.js",
},
},
},
});
},
};
}