-
-
Notifications
You must be signed in to change notification settings - Fork 496
/
vite.config.mts
88 lines (84 loc) · 2.11 KB
/
vite.config.mts
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
/// <reference types="vitest/config" />
import { svelte } from "@sveltejs/vite-plugin-svelte";
import { defineConfig } from "vite";
import { isNotVoid } from "typed-assert";
import replace from "vite-plugin-filter-replace";
import fs from "node:fs";
export default defineConfig((env) => ({
define: {
"process.env.NODE_ENV": JSON.stringify(
process.env.NODE_ENV || "development",
),
},
plugins: [
replace([
{
filter: /release-notes\.ts|main\.ts|README\.md|CHANGELOG\.md/,
replace: [
{
from: "changelogMd",
to: JSON.stringify(fs.readFileSync("./CHANGELOG.md", "utf-8")),
},
{
from: "currentPluginVersion",
to: JSON.stringify(
JSON.parse(fs.readFileSync("./package.json", "utf-8")).version,
),
},
{
from: "supportBanner",
to: JSON.stringify(fs.readFileSync("./support-banner.md", "utf-8")),
},
],
},
]),
svelte({
compilerOptions: {
dev: env.mode === "development",
},
}),
],
css: {
preprocessorOptions: {
scss: { includePaths: ["node_modules"] },
},
},
build: {
// todo: fix
// sourcemap: "inline",
lib: {
entry: ["src/main.ts", "src/styles.scss"],
name: "main",
fileName: () => "main.js",
formats: ["cjs" as const],
},
minify: env.mode === "production",
outDir: ".",
rollupOptions: {
output: {
exports: "named" as const,
assetFileNames: (assetInfo) => {
if (assetInfo.name === "style.css") {
return "styles.css";
}
isNotVoid(assetInfo.name);
return assetInfo.name;
},
},
external: ["obsidian", "electron"],
},
},
test: {
include: ["tests/**/*.test.ts"],
environment: "jsdom",
setupFiles: ["vite-setup.ts"],
coverage: {
reporter: ["html"],
provider: "istanbul",
include: ["src/**/*.ts"],
},
alias: {
obsidian: new URL("./__mocks__/obsidian.ts", import.meta.url).pathname,
},
},
}));