From 93782e714cf70e9eb64323fd43a3bc8fbe94586d Mon Sep 17 00:00:00 2001 From: Josh Thomas Date: Tue, 29 Nov 2016 14:03:19 -0600 Subject: [PATCH] fix(serve): add flag to indicate to serve for a cordova app --- src/dev-server/http-server.ts | 4 ++++ src/dev-server/serve-config.ts | 1 + src/serve.ts | 5 +++++ 3 files changed, 10 insertions(+) diff --git a/src/dev-server/http-server.ts b/src/dev-server/http-server.ts index 186e751d..ddcff74a 100644 --- a/src/dev-server/http-server.ts +++ b/src/dev-server/http-server.ts @@ -99,6 +99,10 @@ function servePlatformResource(req: express.Request, res: express.Response, next const userAgent = req.header('user-agent'); let resourcePath = config.wwwDir; + if (!config.isCordovaServe) { + return next(); + } + if (isUserAgentIOS(userAgent)) { resourcePath = path.join(config.rootDir, IOS_PLATFORM_PATH); } else if (isUserAgentAndroid(userAgent)) { diff --git a/src/dev-server/serve-config.ts b/src/dev-server/serve-config.ts index 99bee865..4381ea06 100644 --- a/src/dev-server/serve-config.ts +++ b/src/dev-server/serve-config.ts @@ -6,6 +6,7 @@ export interface ServeConfig { rootDir: string; wwwDir: string; buildDir: string; + isCordovaServe: boolean; launchBrowser: boolean; launchLab: boolean; browserToLaunch: string; diff --git a/src/serve.ts b/src/serve.ts index e79275cc..504e5354 100644 --- a/src/serve.ts +++ b/src/serve.ts @@ -23,6 +23,7 @@ export function serve(context?: BuildContext) { rootDir: context.rootDir, wwwDir: context.wwwDir, buildDir: context.buildDir, + isCordovaServe: isCordovaServe(context), launchBrowser: launchBrowser(context), launchLab: launchLab(context), browserToLaunch: browserToLaunch(context), @@ -99,6 +100,10 @@ function useServerLogs(context: BuildContext) { return hasConfigValue(context, '--serverlogs', '-s', 'ionic_serverlogs', false); } +function isCordovaServe(context: BuildContext) { + return hasConfigValue(context, '--iscordovaserve', '-z', 'ionic_cordova_serve', false); +} + function launchBrowser(context: BuildContext) { return !hasConfigValue(context, '--nobrowser', '-b', 'ionic_launch_browser', false); }