diff --git a/packages/xarc-app-dev/package.json b/packages/xarc-app-dev/package.json index a84aea7b6..ee00479a0 100644 --- a/packages/xarc-app-dev/package.json +++ b/packages/xarc-app-dev/package.json @@ -141,7 +141,11 @@ "subapp-util": "../subapp-util" }, "devDependencies": { - "@xarc/app": "../xarc-app" + "@xarc/app": "../xarc-app", + "electrode-archetype-opt-postcss": "../electrode-archetype-opt-postcss", + "@xarc/app-dev": "./", + "electrode-archetype-opt-sass": "../electrode-archetype-opt-sass", + "electrode-archetype-opt-stylus": "../electrode-archetype-opt-stylus" } }, "nyc": { diff --git a/packages/xarc-app-dev/src/lib/dev-admin/dev-http.ts b/packages/xarc-app-dev/src/lib/dev-admin/dev-http.ts index 122e26cf0..579fbe0df 100644 --- a/packages/xarc-app-dev/src/lib/dev-admin/dev-http.ts +++ b/packages/xarc-app-dev/src/lib/dev-admin/dev-http.ts @@ -16,14 +16,15 @@ export interface IDevHttpServerOptions { export type HttpRequestEvent = "connect" | "response" | "timeout" | "close" | "finish"; export type HttpServerEvent = "open" | "close" | "listening" | "error"; -export interface IDevHttpServer { +export interface DevHttpServer { webpackDevHttpPlugin: RequestListener; start: () => void; + stop?: () => void; addRequestListener: (event: HttpRequestEvent, handler: any) => void; addServerEventListener: (event: HttpServerEvent, hander: any) => void; } -export const setup = function({ port, host }): IDevHttpServer { +export const setup = function({ port, host }): DevHttpServer { const middleware = new Middleware({ baseUrl: () => { return Url.format({ @@ -75,6 +76,11 @@ export const setup = function({ port, host }): IDevHttpServer { addServerEventListener: (event: HttpServerEvent, cb) => { server.addListener(event.toString(), cb); }, - addRequestListener: (event: HttpRequestEvent, cb: any) => (this.requestEventHooks[event] = cb) + stop: () => { + server.close(function() { + console.log("Server closed!"); + }); + }, + addRequestListener: (event: HttpRequestEvent, cb: any) => (requestEventHooks[event] = cb) }; }; diff --git a/packages/xarc-app-dev/src/lib/dev-admin/dev-server.ts b/packages/xarc-app-dev/src/lib/dev-admin/dev-server.ts index 74785f87e..2684c33c0 100644 --- a/packages/xarc-app-dev/src/lib/dev-admin/dev-server.ts +++ b/packages/xarc-app-dev/src/lib/dev-admin/dev-server.ts @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/no-var-requires */ export {}; -import { IDevHttpServer, setup } from "./dev-http"; +import { DevHttpServer, setup } from "./dev-http"; /* eslint-disable global-require, no-console */ @@ -23,7 +23,7 @@ if (process.env.WEBPACK_DEV === undefined) { } if (http) { - const devHttpServer: IDevHttpServer = setup({ + const devHttpServer: DevHttpServer = setup({ host: archetype.webpack.devHostname, port: archetype.webpack.devPort });