-
Notifications
You must be signed in to change notification settings - Fork 10
/
vite.config.ts
121 lines (118 loc) · 2.87 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
import vue from "@vitejs/plugin-vue";
import path from "path";
import { defineConfig, type UserConfig } from "vite";
import { VitePWA } from "vite-plugin-pwa";
import topLevelAwait from "vite-plugin-top-level-await";
import wasm from "vite-plugin-wasm";
import svgLoader from "vite-svg-loader";
const plugins = [
vue({
script: {
defineModel: true,
propsDestructure: true,
},
}),
svgLoader(),
wasm(),
topLevelAwait(),
VitePWA({
injectRegister: null,
disable: !!process.env.TAURI_PLATFORM || !process.env.VITE_DEV,
workbox: {
globPatterns: ["**/*.{js,css,html,wasm}", "kuromoji-dict-min/*.dat"],
maximumFileSizeToCacheInBytes: 8 * 1024 * 1024,
},
manifest: {
name: "Apple Music-like lyrics TTML Tool",
id: "amll-ttml-tool",
short_name: "AMLL TTML Tool",
description: "一个用于 Apple Music 的逐词歌词 TTML 编辑和时间轴工具",
theme_color: "#18a058",
icons: [
{
src: "./icons/Square30x30Logo.png",
sizes: "30x30",
type: "image/png",
},
{
src: "./icons/Square44x44Logo.png",
sizes: "44x44",
type: "image/png",
},
{
src: "./icons/Square71x71Logo.png",
sizes: "71x71",
type: "image/png",
},
{
src: "./icons/Square89x89Logo.png",
sizes: "89x89",
type: "image/png",
},
{
src: "./icons/Square107x107Logo.png",
sizes: "107x107",
type: "image/png",
},
{
src: "./logo.png",
sizes: "1024x1024",
type: "image/png",
},
{
src: "./logo.svg",
sizes: "128x128",
type: "image/svg",
},
],
},
}),
];
const rollupOptions: UserConfig["build"]["rollupOptions"] = {
output: {
manualChunks(id) {
if (id.includes("naive-ui")) return "naive-ui";
if (id.includes("@pixi")) return "pixi";
if (id.includes("node_modules")) return null;
},
},
};
// https://vitejs.dev/config/
export default defineConfig({
plugins,
base: process.env.TAURI_PLATFORM ? "/" : "./",
// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
// prevent vite from obscuring rust errors
clearScreen: false,
// tauri expects a fixed port, fail if that port is not available
server: {
port: 1420,
strictPort: true,
},
resolve: {
alias: {
"kuromoji": path.resolve(
__dirname,
"libs/kuromoji.js",
),
},
},
// to make use of `TAURI_DEBUG` and other env variables
// https://tauri.studio/v1/api/config#buildconfig.beforedevcommand
envPrefix: ["VITE_", "TAURI_"],
build: process.env.TAURI_PLATFORM
? {
// Tauri supports es2021
target:
process.env.TAURI_PLATFORM === "windows" ? "chrome105" : "safari13",
// don't minify for debug builds
minify: !process.env.TAURI_DEBUG ? "esbuild" : false,
// produce sourcemaps for debug builds
sourcemap: !!process.env.TAURI_DEBUG,
rollupOptions,
}
: {
rollupOptions,
sourcemap: true,
},
});