-
Notifications
You must be signed in to change notification settings - Fork 183
/
Copy pathbuild.config.ts
53 lines (50 loc) · 1.62 KB
/
build.config.ts
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
import { defineBuildConfig } from "unbuild";
export default defineBuildConfig({
rollup: {
inlineDependencies: true,
},
hooks: {
"rollup:options"(_, options) {
for (const output of options.output as any[]) {
// @ts-ignore
output.exports = "named";
}
// Prompts theme
// https://github.com/bombshell-dev/clack/issues/36
options.plugins.push({
name: "@clack/prompts",
transform(code, id) {
if (id.endsWith("@clack/prompts/dist/index.mjs")) {
const replaces = [
["} $", "} $"],
[String.raw`"\u25C6","*"`, '"❯", ">"'],
[String.raw`"\u25A0","x"`, '"■", "x"'],
[String.raw`"\u25B2","x"`, '"▲", "x"'],
[String.raw`"\u25C7","o"`, '"✔", "√"'],
[String.raw`"\u250C","T"`, '""'],
[String.raw`"\u2502","|"`, '""'],
[String.raw`"\u2514","\u2014"`, '""'],
] as const;
for (const [from, to] of replaces) {
code = code.replaceAll(from, to);
}
return code;
}
},
});
// Node.js 14 support
// https://github.com/unjs/consola/issues/204
options.plugins.push({
name: "icu-compat",
transform(code, id) {
if (id.endsWith("string-width/index.js")) {
return code.replace(
"const segmenter = new Intl.Segmenter();",
"const segmenter = globalThis.Intl?.Segmenter ? new Intl.Segmenter() : { segment: (str) => str.split('') };",
);
}
},
});
},
},
});