2025-11-04 16:16:50 +01:00
|
|
|
import { defineConfig } from 'vite';
|
2026-10-01 02:06:00 +02:00
|
|
|
import { svelte, vitePreprocess } from '@sveltejs/vite-plugin-svelte';
|
2025-11-04 16:16:50 +01:00
|
|
|
import resolve from '@rollup/plugin-node-resolve';
|
|
|
|
|
import livereload from 'rollup-plugin-livereload';
|
|
|
|
|
|
|
|
|
|
const production = process.env.NODE_ENV === "production"
|
|
|
|
|
console.log("Production mode:", production)
|
|
|
|
|
|
|
|
|
|
const builddir = "../res/static/svelte"
|
|
|
|
|
|
|
|
|
|
export default defineConfig({
|
|
|
|
|
mode: production ? "production" : "development",
|
2026-10-01 02:06:00 +02:00
|
|
|
// Chunks are loaded relative to the script which imports them
|
|
|
|
|
base: "./",
|
2025-11-04 16:16:50 +01:00
|
|
|
build: {
|
|
|
|
|
outDir: builddir,
|
|
|
|
|
emptyOutDir: true,
|
|
|
|
|
minify: production,
|
2026-01-30 12:26:36 +01:00
|
|
|
sourcemap: !production,
|
2026-10-01 02:06:00 +02:00
|
|
|
// Compile newer syntax down to what browsers from September 2021 support
|
|
|
|
|
target: ["chrome94", "edge94", "firefox91", "safari15"],
|
|
|
|
|
rollupOptions: {
|
|
|
|
|
input: "src/wrap.js",
|
|
|
|
|
// The entrypoint keeps its name so the HTML template can find it,
|
|
|
|
|
// the chunks it imports get a hash in their names
|
|
|
|
|
output: { entryFileNames: "wrap.js" },
|
|
|
|
|
},
|
2025-11-04 16:16:50 +01:00
|
|
|
},
|
|
|
|
|
plugins: [
|
2026-10-01 02:06:00 +02:00
|
|
|
// Svelte can't strip TypeScript enums by itself
|
|
|
|
|
svelte({ preprocess: vitePreprocess({ script: true }), emitCss: false }),
|
2025-11-04 16:16:50 +01:00
|
|
|
|
2026-10-01 02:06:00 +02:00
|
|
|
// Resolves imports relative to the src directory, like "lib/NovaAPI"
|
2025-11-04 16:16:50 +01:00
|
|
|
resolve({
|
|
|
|
|
browser: true,
|
|
|
|
|
exportConditions: ['svelte'],
|
|
|
|
|
modulePaths: [process.cwd() + "/src", process.cwd() + "/node_modules"],
|
|
|
|
|
extensions: [".svelte", ".mjs", ".js", ".json", ".mts", ".ts"],
|
|
|
|
|
}),
|
|
|
|
|
|
2026-10-01 02:06:00 +02:00
|
|
|
// Refresh the browser when the build changes
|
2025-11-04 16:16:50 +01:00
|
|
|
!production && livereload({
|
2026-10-01 02:06:00 +02:00
|
|
|
watch: builddir,
|
2025-11-04 16:16:50 +01:00
|
|
|
port: 5000,
|
|
|
|
|
}),
|
2026-10-01 02:06:00 +02:00
|
|
|
],
|
2025-11-04 16:16:50 +01:00
|
|
|
});
|