Skip to content

Commit

Permalink
feature: start api will start server
Browse files Browse the repository at this point in the history
  • Loading branch information
phshy0607 committed Mar 31, 2022
1 parent 2f80e1e commit 0565979
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fix
- fix `types` is missing in `package.json`
- fix react-frame-component does not provide an export named `default`

### Added
- add `exports` in `package.json`

### Changed
- `start` api will start server

## [0.6.5] - 2022-03-30

### Added
Expand Down
9 changes: 3 additions & 6 deletions src/node/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,9 @@ let server: ViteDevServer = null;
const bootstrap = () => {
readUserConfigFile(configFilePath).then((userConfig) => {
if (command === "start") {
start(merge({ root }, userConfig))
.then((s) => s.listen())
.then((s) => {
server = s;
s.printUrls();
});
start(merge({ root }, userConfig)).then((s) => {
server = s;
});
}
if (command === "build") {
build(merge({ root }, userConfig));
Expand Down
19 changes: 12 additions & 7 deletions src/node/start.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import { createServer as createViteServer } from 'vite';
import { resolveConfig } from './config.js';
import { UserConfig } from './types.js';
import { docit } from './plugins/index.js';
import { createServer as createViteServer } from "vite";
import { resolveConfig } from "./config.js";
import { UserConfig } from "./types.js";
import { docit } from "./plugins/index.js";

export const start = async (userConfig: UserConfig) => {
const config = await resolveConfig(userConfig, 'start');
const config = await resolveConfig(userConfig, "start");
return createViteServer({
base: '/',
base: "/",
plugins: [await docit(config)],
});
})
.then((s) => s.listen())
.then((s) => {
s.printUrls();
return s;
});
};

0 comments on commit 0565979

Please sign in to comment.