generated from JohnBra/vite-web-extension
-
Notifications
You must be signed in to change notification settings - Fork 14
/
vite.config.ts
57 lines (55 loc) · 1.95 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
56
57
import react from "@vitejs/plugin-react-swc";
import { config } from "dotenv";
import { resolve } from "path";
import { defineConfig } from "vite";
import checkLocalesForMissingKeys from "./src/utils/checkLocalesForMissingKeys";
import { ENABLE_SOURCE_MAP } from "./src/utils/constants";
import buildContentScript from "./src/utils/plugins/build-content-script";
import copyBuild from "./src/utils/plugins/copy-build";
import copyPublic from "./src/utils/plugins/copy-public";
import makeManifest from "./src/utils/plugins/make-manifest";
import makeReleaseZips from "./src/utils/plugins/make-release-zips";
import replaceDevModeConst from "./src/utils/plugins/replace-dev-mode-const";
import { assetsDir, componentsDir, emptyOutputFolder, hooksDir, outDir, pagesDir, srcDir, utilsDir } from "./src/utils/plugins/utils";
import updateAvailableLocales from "./src/utils/updateAvailableLocales";
import updateLocalePercentages from "./src/utils/updateLocalePercentages";
config();
export default function build() {
emptyOutputFolder();
void updateAvailableLocales();
if (process.env.__DEV__ !== "true") {
void checkLocalesForMissingKeys();
void updateLocalePercentages();
}
return defineConfig({
build: {
emptyOutDir: false,
modulePreload: false,
outDir: resolve(outDir, "temp"),
rollupOptions: {
input: {
background: resolve(pagesDir, "background", "index.html"),
options: resolve(pagesDir, "options", "index.html"),
popup: resolve(pagesDir, "popup", "index.html")
},
output: {
entryFileNames: (chunk) => {
return `src/pages/${chunk.name}/index.js`;
}
}
},
sourcemap: ENABLE_SOURCE_MAP
},
plugins: [replaceDevModeConst(), react(), makeManifest(), buildContentScript(), copyPublic(), copyBuild(), makeReleaseZips()],
resolve: {
alias: {
"@/assets": assetsDir,
"@/components": componentsDir,
"@/hooks": hooksDir,
"@/pages": pagesDir,
"@/src": srcDir,
"@/utils": utilsDir
}
}
});
}