2024-07-30 17:45:27 +00:00
|
|
|
import path from "node:path";
|
|
|
|
import { defineConfig } from "vite";
|
|
|
|
import vue from "@vitejs/plugin-vue";
|
|
|
|
import VueI18nPlugin from "@intlify/unplugin-vue-i18n/vite";
|
|
|
|
import { compression } from "vite-plugin-compression2";
|
|
|
|
|
|
|
|
const plugins = [
|
|
|
|
vue(),
|
|
|
|
VueI18nPlugin({
|
|
|
|
include: [path.resolve(__dirname, "./src/i18n/**/*.json")],
|
|
|
|
}),
|
|
|
|
compression({
|
|
|
|
include: /\.(js|woff2|woff)(\?.*)?$/i,
|
|
|
|
deleteOriginalAssets: true,
|
|
|
|
}),
|
|
|
|
];
|
|
|
|
|
|
|
|
const resolve = {
|
|
|
|
alias: {
|
|
|
|
"@": path.resolve(__dirname, "src"),
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
// https://vitejs.dev/config/
|
|
|
|
export default defineConfig(({ command }) => {
|
2024-11-26 17:21:41 +00:00
|
|
|
return {
|
|
|
|
plugins,
|
|
|
|
resolve,
|
|
|
|
base: "",
|
|
|
|
build: {
|
|
|
|
rollupOptions: {
|
|
|
|
input: {
|
|
|
|
index: path.resolve(__dirname, "./public/index.html"),
|
2024-07-30 17:45:27 +00:00
|
|
|
},
|
2024-11-26 17:21:41 +00:00
|
|
|
output: {
|
|
|
|
manualChunks: (id) => {
|
|
|
|
if (id.includes("i18n/")) {
|
|
|
|
return "i18n";
|
|
|
|
}
|
2024-07-30 17:45:27 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2024-11-26 17:21:41 +00:00
|
|
|
},
|
|
|
|
experimental: {
|
|
|
|
renderBuiltUrl(filename, { hostType }) {
|
|
|
|
if (hostType === "js") {
|
|
|
|
return { runtime: `window.__prependStaticUrl("${filename}")` };
|
|
|
|
} else if (hostType === "html") {
|
|
|
|
return `{{ .StaticURL }}/${filename}`;
|
|
|
|
} else {
|
|
|
|
return { relative: true };
|
|
|
|
}
|
2024-07-30 17:45:27 +00:00
|
|
|
},
|
2024-11-26 17:21:41 +00:00
|
|
|
},
|
|
|
|
test: {
|
|
|
|
globals: true,
|
2024-12-26 17:31:04 +00:00
|
|
|
include: ["src/**/*.test.js"],
|
|
|
|
exclude: ["src/**/*.vue"],
|
|
|
|
environment: "jsdom",
|
|
|
|
setupFiles: "tests/mocks/setup.js",
|
2024-11-26 17:21:41 +00:00
|
|
|
},
|
|
|
|
};
|
2024-07-30 17:45:27 +00:00
|
|
|
});
|