-
Notifications
You must be signed in to change notification settings - Fork 1
/
vite.config.ts
66 lines (63 loc) · 1.98 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
58
59
60
61
62
63
64
65
66
import { resolve } from "path";
import { defineConfig } from "vite";
import eslint from "vite-plugin-eslint";
import browserslist from "browserslist";
import { browserslistToTargets } from "lightningcss";
import { createHtmlPlugin } from "vite-plugin-html";
import { createWriteStream, existsSync, mkdirSync } from "fs";
if (!existsSync("node_modules/jszip/dist/jszip.js")) {
mkdirSync("node_modules/jszip/dist");
// Hack required to get ePub.js to build without jszip
const writeStream = createWriteStream("node_modules/jszip/dist/jszip.js");
writeStream.write("module.exports = {};");
writeStream.end();
}
export default defineConfig({
// prevent vite from obscuring rust errors
clearScreen: false,
// Tauri expects a fixed port, fail if that port is not available
server: {
strictPort: true,
},
// to access the Tauri environment variables set by the CLI with information about the current target
envPrefix: [
"VITE_",
"TAURI_ENV_PLATFORM",
"TAURI_ENV_ARCH",
"TAURI_ENV_FAMILY",
"TAURI_ENV_PLATFORM_VERSION",
"TAURI_ENV_PLATFORM_TYPE",
"TAURI_ENV_DEBUG",
],
build: {
// Tauri uses Edge on Windows and WebKit on macOS and Linux
target: process.env.TAURI_ENV_PLATFORM == "windows" ? "edge89" : "safari15",
minify: "terser",
cssMinify: "lightningcss",
rollupOptions: {
input: {
main: resolve(__dirname, "index.html"),
viewer: resolve(__dirname, "viewer.html"),
subviewer: resolve(__dirname, "subviewer.html"),
error: resolve(__dirname, "error.html"),
navigator: resolve(__dirname, "navigator.html"),
settings: resolve(__dirname, "settings.html"),
guide: resolve(__dirname, "guide.html"),
},
},
},
css: {
transformer: "lightningcss",
lightningcss: {
targets: browserslistToTargets(
browserslist(
// Tauri uses Edge on Windows and WebKit on macOS and Linux
process.env.TAURI_ENV_PLATFORM == "windows"
? "edge>=89"
: "safari>=15",
),
),
},
},
plugins: [eslint(), createHtmlPlugin({ minify: true })],
});