-
Notifications
You must be signed in to change notification settings - Fork 4
/
vite.config.js
48 lines (30 loc) · 947 Bytes
/
vite.config.js
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
import { spawnSync } from "child_process";
import { defineConfig } from "vite";
function isDev() {
return process.env.NODE_ENV !== "production";
}
function printSbtTask(task) {
const args = ["--error", "--batch", `print ${task}`];
const options = {
stdio: [
"pipe", // StdIn.
"pipe", // StdOut.
"inherit", // StdErr.
],
};
const result = process.platform === 'win32'
? spawnSync("sbt.bat", args.map(x => `"${x}"`), {shell: true, ...options})
: spawnSync("sbt", args, options);
if (result.error)
throw result.error;
if (result.status !== 0)
throw new Error(`sbt process failed with exit code ${result.status}`);
return result.stdout.toString('utf8').trim();
}
const linkOutputDir =
printSbtTask(isDev() ? "fastLinkOutputDir" : "fullLinkOutputDir");
export default defineConfig({
resolve: {
alias: [ { find: "@linkOutputDir", replacement: linkOutputDir } ]
}
});