Files
continuwuity/packages/website/vite.config.ts
T

68 lines
1.8 KiB
TypeScript
Raw Normal View History

2024-05-01 18:34:30 +01:00
import { sveltekit } from "@sveltejs/kit/vite";
import { defineConfig } from "vite";
import { ViteImageOptimizer } from "vite-plugin-image-optimizer";
import dynamicImport from 'vite-plugin-dynamic-import'
import typeAsJsonSchemaPlugin from "rollup-plugin-type-as-json-schema";
import dynamicImportVars from '@rollup/plugin-dynamic-import-vars';
2024-05-03 13:29:44 +01:00
import path from "node:path";
2024-05-01 18:34:30 +01:00
import { mdsvex } from 'mdsvex';
import mdsvexConfig from "./mdsvex.config.js";
import { extname } from 'node:path';
2024-02-13 16:38:14 +00:00
2024-05-01 18:34:30 +01:00
function mdsvex_transform() {
return {
name: "Mdsvex transformer",
async transform(code: string, id: string) {
if (extname(id) !== ".md") return;
const c = (
await mdsvex(mdsvexConfig).markup({ content: code, filename: id })
)?.code;
return c;
// return `export default \`${c.replace(/`/g, "\\`").trim()}\`;`;
}
};
}
2024-02-13 16:38:14 +00:00
export default defineConfig({
2024-05-01 18:34:30 +01:00
resolve: {
alias: {
2024-05-03 13:29:44 +01:00
"Notes": path.join(__dirname, "node_modules/Notes")
2024-05-01 18:34:30 +01:00
}
},
plugins: [
typeAsJsonSchemaPlugin(),
2024-05-01 18:34:30 +01:00
ViteImageOptimizer({
/* pass your config */
}),
// mdsvex_transform(),
sveltekit(),
dynamicImport({
2024-05-03 13:29:44 +01:00
filter(id) {
if (id.includes('node_modules/Notes')) {
return true
}
}
2024-05-01 18:34:30 +01:00
}),
// dynamicImportVars({
// // options
// })
],
build: {
assetsInlineLimit: 0,
},
optimizeDeps: {
exclude: [
2024-05-01 18:34:30 +01:00
"codemirror",
// "@codemirror/lang-javascript",
// "@codemirror/state",
// "@codemirror/lint",
// "@codemirror/autocomplete",
// "@codemirror/language",
// "thememirror"
/* ... */
],
},
2024-02-13 16:38:14 +00:00
});