Skip to content

Commit 425c37d

Browse files
committed
fix: build serving via express
1 parent f31c26a commit 425c37d

File tree

3 files changed

+40
-13
lines changed

3 files changed

+40
-13
lines changed

Parse-Dashboard/app.js

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,7 +1140,7 @@ You have direct access to the Parse database through function calls, so you can
11401140
if (users && req.user && req.user.matchingUsername) {
11411141
res.append('username', req.user.matchingUsername);
11421142
}
1143-
if (!req.path.startsWith(`${mountPath}v2`)) {
1143+
if (!req.path.startsWith('/v2')) {
11441144
res.send(`<!DOCTYPE html>
11451145
<html>
11461146
<head>
@@ -1159,7 +1159,26 @@ You have direct access to the Parse database through function calls, so you can
11591159
</html>
11601160
`);
11611161
} else {
1162-
next();
1162+
if (options.dev) {
1163+
next();
1164+
} else {
1165+
res.send(`<!doctype html>
1166+
<html lang="en">
1167+
<head>
1168+
<base href="${mountPath}v2/"/>
1169+
<meta charset="UTF-8" />
1170+
<link rel="icon" type="image/svg+xml" href="${mountPath}v2/vite.bundle.svg" />
1171+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
1172+
<title>Express serve</title>
1173+
<script type="module" crossorigin src="${mountPath}v2/index.bundle.js"></script>
1174+
<link rel="stylesheet" crossorigin href="${mountPath}v2/index.bundle.css">
1175+
</head>
1176+
<body>
1177+
<div id="root"></div>
1178+
</body>
1179+
</html>
1180+
`);
1181+
}
11631182
}
11641183
});
11651184
});

Parse-Dashboard/server.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -199,17 +199,19 @@ module.exports = options => {
199199
)}`
200200
);
201201
});
202-
ViteExpress.config({
203-
inlineViteConfig: {
204-
base: '/v2/',
205-
root: path.join(__dirname, '../v2'),
206-
build: {
207-
outDir: path.join(__dirname, './v2'),
202+
if (dev) {
203+
ViteExpress.config({
204+
inlineViteConfig: {
205+
base: `${mountPath}/v2/`,
206+
root: path.join(__dirname, '../v2'),
207+
build: {
208+
outDir: path.join(__dirname, './v2'),
209+
},
208210
},
209-
},
210-
mode: dev && fs.existsSync(path.join(__dirname, '../v2')) ? 'development' : 'production',
211-
});
212-
ViteExpress.bind(app, server);
211+
mode: dev && fs.existsSync(path.join(__dirname, '../v2')) ? 'development' : 'production',
212+
});
213+
ViteExpress.bind(app, server);
214+
}
213215
} else {
214216
// Start the server using SSL.
215217
const privateKey = fs.readFileSync(configSSLKey);

v2/vite.config.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,14 @@ import react from '@vitejs/plugin-react-swc';
55
export default defineConfig({
66
plugins: [react()],
77
build: {
8-
outDir: '../Parse-Dashboard/v2',
8+
outDir: '../Parse-Dashboard/public/v2',
99
emptyOutDir: true,
10+
rollupOptions: {
11+
output: {
12+
entryFileNames: '[name].bundle.js',
13+
assetFileNames: '[name].bundle.[ext]',
14+
},
15+
},
1016
},
1117
base: '/v2/',
1218
});

0 commit comments

Comments
 (0)