generated from keynmol/laminar-static-gh-pages
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.js
44 lines (39 loc) · 1.1 KB
/
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
36
37
38
39
40
41
42
43
44
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}`);
const results = result.stdout.toString('utf8').replace(/(\r\n|\n|\r)/gm, "");
console.log(`got from SBT trimmed: "${results}"`);
return results;
}
const replacementForPublic = isDev()
? printSbtTask("fastLinkJSOutput")
: printSbtTask("fullLinkJSOutput");
export default defineConfig({
resolve: {
preserveSymlinks: true,
alias: [
{
find: "/generated-public",
replacement: replacementForPublic,
},
],
},
});