Skip to content

Commit

Permalink
feat: devServer init
Browse files Browse the repository at this point in the history
  • Loading branch information
c0dedance committed Oct 12, 2023
1 parent 57cef44 commit 4200d39
Show file tree
Hide file tree
Showing 4 changed files with 324 additions and 4 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"typescript": "^5.2.2"
},
"dependencies": {
"cac": "^6.7.14"
"cac": "^6.7.14",
"vite": "^4.4.11"
}
}
309 changes: 307 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion src/node/cli.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import path = require("path");
import { cac } from "cac";
import { createDevServer } from "./dev";

const { version } = require("../../package.json");

Expand All @@ -8,7 +10,11 @@ cli
.command("[root]", "start dev server")
.alias("dev")
.action(async (root: string) => {
console.log("dev", root);
root = root ? path.resolve(root) : process.cwd();
const server = await createDevServer(root);
await server.listen();
server.printUrls();

});

cli
Expand Down
8 changes: 8 additions & 0 deletions src/node/dev.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { createServer as createViteDevServer } from "vite";


export function createDevServer(root: string = process.cwd()) {
return createViteDevServer({
root,
})
}

0 comments on commit 4200d39

Please sign in to comment.