-
Notifications
You must be signed in to change notification settings - Fork 6
/
vite.config.js
56 lines (49 loc) · 1.48 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
45
46
47
48
49
50
51
52
53
54
55
56
import { spawnSync } from "child_process";
import { defineConfig } from "vite";
// Config project name and web files directory
var projectName = "frontend"
var projectWebFiles = "web"
function isDev() {
return process.env.NODE_ENV !== "production";
}
function printMillTask(task) {
const args = ["-s", "--no-server", "--disable-ticker", `${projectName}.${task}`];
const options = {
stdio: [
"pipe", // StdIn.
"pipe", // StdOut.
"inherit", // StdErr.
],
};
const result = process.platform === 'win32'
? spawnSync("./mill.bat", args.map(x => `"${x}"`), { shell: true, ...options })
: spawnSync("./mill", args, options);
if (result.error)
throw result.error;
if (result.status !== 0)
throw new Error(`mill process failed with exit code ${result.status}`);
return result.stdout.toString('utf8').trim().split('\n').slice(-1)[0];
}
const linkOutputDir = isDev()
? printMillTask("fastLinkOut")
: printMillTask("fullLinkOut");
export default defineConfig({
root: `${projectName}/${projectWebFiles}`,
resolve: {
alias: [
{
find: "@linkOutputDir",
replacement: linkOutputDir,
},
],
},
build: {
outDir: "../../dist",
rollupOptions: {
// https://rollupjs.org/guide/en/#big-list-of-options
output: {
dir: "./dist",
},
}
}
});