1
0
mirror of https://github.com/MultiMote/niimblue synced 2026-01-19 19:37:11 +03:00
Files
niimblue/vite.config.ts
MultiMote a5f741035f Cleanup svelte5 migration
Squash summary:

* Fix PrinterConnector loop keys
* Remove unnecessary state
* Add format-all script, remove esbuild override
* Use localStorage key as SavedLabelsBrowser element key
* Remove prettier.config.ts because .prettierrc.yml exists
* Remove unused eslint plugins, migrate config
* Change npm scripts
* Fix state typing
* Finish root path alias, range type
* Get rid of "possibly undefined" errors
* Replace $effect with $derived
* Fix key errors
* Replace legacy run() with $effect
* Enable runes explicitly
* Remove FabricConfig.disableStyleCopyPaste duplicate
* Revert capacitor changes in base project
* Revert .gitignore
* Remove eslint comment
* Revert dashboard to MainPage (not using kit, no routes)
2025-11-27 11:59:03 +03:00

61 lines
1.7 KiB
TypeScript

import { defineConfig } from "vite";
import { svelte } from "@sveltejs/vite-plugin-svelte";
import { resolve } from "node:path";
const getDate = (): string => {
const date = new Date();
const fmt = (n: number) => (n > 9 ? n : `0${n}`);
return `${date.getFullYear()}-${fmt(date.getMonth() + 1)}-${fmt(date.getDate())}`;
};
// https://vitejs.dev/config/
export default defineConfig({
plugins: [svelte()],
define: {
__APP_VERSION__: JSON.stringify(process.env.npm_package_version),
__APP_COMMIT__: JSON.stringify(process.env.COMMIT_HASH),
__BUILD_DATE__: JSON.stringify(getDate()),
},
optimizeDeps: {
include: ["@mmote/niimbluelib"], // Fix browser error when using `npm link @mmote/niimbluelib`
},
resolve: {
preserveSymlinks: true, // Fix build error when using `npm link @mmote/niimbluelib`
alias: {
$: resolve(__dirname, "./src")
},
},
build: {
rollupOptions: {
output: {
manualChunks: (id: string) => {
if (id.endsWith(".css") || id.endsWith(".scss")) {
return "style";
}
if (id.includes("node_modules")) {
if (id.includes("fabric")) {
return "lib.2.fabric";
} else if (
id.includes("@capacitor/filesystem") ||
id.includes("@capacitor/share")
) {
return "lib.2.cap";
} else if (id.includes("zod")) {
return "lib.2.zod";
} else if (id.includes("@mmote/niimbluelib")) {
return "lib.2.niim";
}
return "lib.1.other";
}
return null;
},
chunkFileNames: () => {
return "assets/[name].[hash].js";
},
},
},
},
});