-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnuxt.config.ts
122 lines (117 loc) · 3.19 KB
/
nuxt.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
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
// https://nuxt.com/docs/api/configuration/nuxt-config
import { defineNuxtConfig } from "nuxt/config";
import pkg from "./package.json";
import { dirname } from "path";
const electron = process.argv.includes("--electron");
const ghpages = process.argv.includes("--ghpages");
function getGitHubRepo() {
return pkg.build.publish[0].repo;
}
if (ghpages) {
console.log("ghpages repo", `/${getGitHubRepo()}/`);
}
export default defineNuxtConfig({
ssr: false,
sourcemap: {
server: true,
client: true,
},
runtimeConfig: {
public: {
editor: true,
electron: electron,
ghpages: ghpages,
clientVersion: pkg.version,
},
},
modules: [
"nuxt-windicss",
"@pinia/nuxt",
"@pinia-plugin-persistedstate/nuxt",
...(electron ? ["nuxt-electron"] : []),
],
app: ghpages
? {
baseURL: `/${pkg.build.publish[0].repo}/`,
head: {
title: "New Recruit - Editor",
...(ghpages
? {
base: {
href: `/${getGitHubRepo()}/`,
},
}
: {}),
},
}
: undefined,
// @ts-ignore
plugins: [
...(electron
? [
{
mode: "client",
src: "electron/renderer.ts",
},
]
: []),
],
typescript: {
strict: true,
},
electron: {
build: [
{
entry: "electron/main.ts",
vite: {
resolve: {
alias: {
"~": dirname(__filename),
"@": dirname(__filename),
"~~": dirname(__filename),
"@@": dirname(__filename),
"assets": `${dirname(__filename)}/assets`,
"public": `${dirname(__filename)}/public`
}
},
build: {
sourcemap: true,
rollupOptions: {
output: {
// Setting format to 'iife' for a self-executing function, or 'umd' for universal module definition
format: 'umd', // or 'umd'
// Optionally, you can name your module, useful especially for 'umd' format
name: 'main.js'
}
}
}
}
},
{ entry: "electron/preload.js" }
],
},
css: ["~/shared_components/css/vars.scss", "~/shared_components/css/style.scss"],
vite: {
plugins: [require("vite-plugin-commonjs")()],
},
ignore: [".release/**"],
hooks: {
"nitro:build:public-assets"(nitro) {
if (electron) {
const outputDir = nitro.options.output.publicDir;
const { copyFileSync } = require("fs");
// copyFileSync("electron/main.js", `${outputDir}/main.js`);
// copyFileSync("electron/preload.js", `${outputDir}/preload.js`);
copyFileSync("dist-electron/main.js", `${outputDir}/main.js`);
copyFileSync("dist-electron/preload.js", `${outputDir}/preload.js`);
copyFileSync("package.json", `${outputDir}/package.json`);
}
if (ghpages) {
const { writeFileSync, readdirSync } = require("fs");
const outputDir = nitro.options.output.publicDir;
writeFileSync(`${outputDir}/.nojekyll`, "");
}
},
},
components: [{ path: "~/shared_components/" }, { path: "~/components/" }],
});