-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrolldown.config.ts
More file actions
79 lines (70 loc) · 2.16 KB
/
rolldown.config.ts
File metadata and controls
79 lines (70 loc) · 2.16 KB
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
import { glob, rm } from "@goodbyenjn/utils/fs";
import { defineConfig } from "rolldown";
import packageJson from "./package.json";
const isWatchMode = process.env["ROLLDOWN_WATCH"] === "true";
const { version, description, author, obsidian } = packageJson;
const { id, name, isDesktopOnly, minAppVersion } = obsidian;
const manifest = JSON.stringify(
{
id: id + (isWatchMode ? "-dev" : ""),
name: name + (isWatchMode ? " (Dev)" : ""),
version,
author: author.name,
authorUrl: author.url,
description,
isDesktopOnly,
minAppVersion,
} satisfies Manifest,
null,
4,
);
export default defineConfig({
input: ["src/main.ts", "src/styles.css"],
output: {
dir: "dist",
format: "cjs",
minify: true,
},
external: ["obsidian", "electron"],
moduleTypes: {},
transform: {
define: {
"process.env.MANIFEST": manifest,
},
},
plugins: [
{
name: "plugin:cleanup",
async generateBundle(options) {
const dir = options.dir!;
const files = await glob("*", {
cwd: dir,
ignore: "data.json",
dot: true,
absolute: true,
});
await Promise.all(files.map(file => rm(file)));
},
},
{
name: "plugin:assets",
async generateBundle(_, bundle) {
// Remove the styles.js file generated by the styles.css entry point, since the CSS support in Rolldown is currently imcomplete.
// https://github.com/rolldown/rolldown/issues/4271
delete bundle["styles.js"];
this.emitFile({
type: "asset",
fileName: "manifest.json",
source: manifest,
});
if (isWatchMode) {
this.emitFile({
type: "asset",
fileName: ".hotreload",
source: "",
});
}
},
},
],
});