Seperator 컴포넌트 추가 및 페이지에서 사용, 스타일 수정
This commit is contained in:
parent
6f7257e944
commit
002b071c72
5 changed files with 213 additions and 118 deletions
|
|
@ -3,41 +3,65 @@ import index from "./index.html";
|
|||
|
||||
// Parse command line arguments for port
|
||||
const args = process.argv.slice(2);
|
||||
const portArgIndex = args.findIndex(arg => arg === "--port");
|
||||
const port = portArgIndex !== -1 && args[portArgIndex + 1] ?
|
||||
parseInt(args[portArgIndex + 1]) : 3000;
|
||||
const portArgIndex = args.findIndex((arg) => arg === "--port");
|
||||
const defaultPort =
|
||||
portArgIndex !== -1 && args[portArgIndex + 1]
|
||||
? parseInt(args[portArgIndex + 1])
|
||||
: 3000;
|
||||
|
||||
|
||||
const server = serve({
|
||||
port: port,
|
||||
routes: {
|
||||
// Serve index.html for all unmatched routes.
|
||||
"/*": index,
|
||||
"/timeline": Response.redirect("/#timeline"),
|
||||
"/ads.txt": new Response(
|
||||
"google.com, pub-4588517451789913, DIRECT, f08c47fec0942fa0",
|
||||
{
|
||||
headers: {
|
||||
"content-type": "text/plain",
|
||||
// Function to find available port
|
||||
async function findAvailablePort(startPort: number): Promise<number> {
|
||||
let port = startPort;
|
||||
while (port < 65535) {
|
||||
try {
|
||||
const testServer = serve({
|
||||
port: port,
|
||||
fetch() {
|
||||
return new Response("test");
|
||||
},
|
||||
},
|
||||
),
|
||||
},
|
||||
|
||||
development: process.env.NODE_ENV !== "production" && {
|
||||
// Enable browser hot reloading in development
|
||||
hmr: true,
|
||||
|
||||
// Echo console logs from the browser to the server
|
||||
console: true,
|
||||
},
|
||||
});
|
||||
|
||||
console.clear();
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
console.log(`\x1b[45m Dev \x1b[0m\x1b[35m Bun v${Bun.version}\x1b[0m`);
|
||||
} else {
|
||||
console.log(`\x1b[0m\x1b[35m Bun v${Bun.version}\x1b[0m`);
|
||||
});
|
||||
testServer.stop();
|
||||
return port;
|
||||
} catch (error) {
|
||||
port++;
|
||||
}
|
||||
}
|
||||
throw new Error("No available port found");
|
||||
}
|
||||
console.log(`\n\x1b[34m→ \x1b[35m${server.url}\x1b[0m`);
|
||||
|
||||
(async () => {
|
||||
const port = await findAvailablePort(defaultPort);
|
||||
|
||||
const server = serve({
|
||||
port: port,
|
||||
routes: {
|
||||
// Serve index.html for all unmatched routes.
|
||||
"/*": index,
|
||||
"/timeline": Response.redirect("/#timeline"),
|
||||
"/ads.txt": new Response(
|
||||
"google.com, pub-4588517451789913, DIRECT, f08c47fec0942fa0",
|
||||
{
|
||||
headers: {
|
||||
"content-type": "text/plain",
|
||||
},
|
||||
}
|
||||
),
|
||||
},
|
||||
|
||||
development: process.env.NODE_ENV !== "production" && {
|
||||
// Enable browser hot reloading in development
|
||||
hmr: true,
|
||||
|
||||
// Echo console logs from the browser to the server
|
||||
console: true,
|
||||
},
|
||||
});
|
||||
|
||||
console.clear();
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
console.log(`\x1b[45m Dev \x1b[0m\x1b[35m Bun v${Bun.version}\x1b[0m`);
|
||||
} else {
|
||||
console.log(`\x1b[0m\x1b[35m Bun v${Bun.version}\x1b[0m`);
|
||||
}
|
||||
console.log(`\n\x1b[34m→ \x1b[35m${server.url}\x1b[0m`);
|
||||
})();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue