mirror of
https://github.com/vector-im/element-call.git
synced 2024-11-15 00:04:59 +08:00
Add dev server
This commit is contained in:
parent
03379ac1a7
commit
8841784cae
993
package-lock.json
generated
993
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -2,6 +2,7 @@
|
||||
"version": "0.0.0",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"dev-server": "node ./server.js",
|
||||
"build": "vite build",
|
||||
"serve": "vite preview"
|
||||
},
|
||||
@ -15,6 +16,8 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-react-refresh": "^1.3.1",
|
||||
"express": "^4.17.1",
|
||||
"http2-proxy": "^5.0.53",
|
||||
"vite": "^2.4.2"
|
||||
}
|
||||
}
|
||||
|
46
server.js
Normal file
46
server.js
Normal file
@ -0,0 +1,46 @@
|
||||
const express = require("express");
|
||||
const { createServer: createViteServer } = require("vite");
|
||||
const proxy = require("http2-proxy");
|
||||
|
||||
async function createServer() {
|
||||
const app = express();
|
||||
|
||||
app.use("/_matrix*", (req, res, next) => {
|
||||
proxy.web(
|
||||
req,
|
||||
res,
|
||||
{
|
||||
hostname: "localhost",
|
||||
port: 8008,
|
||||
},
|
||||
(err) => {
|
||||
if (err) {
|
||||
console.error(
|
||||
`Error http://localhost:3000${req.originalUrl} -> http://localhost:8008${req.originalUrl}`,
|
||||
err
|
||||
);
|
||||
next(err);
|
||||
} else {
|
||||
console.log(
|
||||
`http://localhost:3000${req.originalUrl} -> http://localhost:8008${req.originalUrl}`
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// Create vite server in middleware mode.
|
||||
const vite = await createViteServer({
|
||||
server: { middlewareMode: "html" },
|
||||
});
|
||||
// Use vite's connect instance as middleware
|
||||
app.use(vite.middlewares);
|
||||
|
||||
app.listen(3000);
|
||||
}
|
||||
|
||||
createServer()
|
||||
.then(() => {
|
||||
console.log("Listening on http://localhost:3000");
|
||||
})
|
||||
.catch((err) => console.error(err));
|
@ -22,7 +22,7 @@ export default defineConfig({
|
||||
plugins: [reactRefresh()],
|
||||
server: {
|
||||
proxy: {
|
||||
"/_matrix": "http://localhost:8080",
|
||||
"/_matrix": "http://localhost:8008",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user