From 30b2c9af4f2effc6f0a0dab12a9992c8d688b0ff Mon Sep 17 00:00:00 2001 From: Noel De Martin Date: Mon, 2 Aug 2021 13:27:15 +0200 Subject: [PATCH] MOBILE-3825 DX: Fix ionic:serve hook --- package.json | 2 +- scripts/serve.sh | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100755 scripts/serve.sh diff --git a/package.json b/package.json index 01beb7354..7758f7bdc 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "test:coverage": "NODE_ENV=testing gulp && jest --coverage", "lint": "NODE_OPTIONS=--max-old-space-size=4096 ng lint", "ionic:serve:before": "gulp", - "ionic:serve": "gulp watch & NODE_OPTIONS=--max-old-space-size=4096 ng serve", + "ionic:serve": "./scripts/serve.sh", "ionic:build:before": "gulp" }, "dependencies": { diff --git a/scripts/serve.sh b/scripts/serve.sh new file mode 100755 index 000000000..393ebc86f --- /dev/null +++ b/scripts/serve.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +# This script is necessary because @ionic/cli is passing one argument to the ionic:serve hook +# that is unsupported by angular cli: https://github.com/ionic-team/ionic-cli/issues/4743 +# +# Once the issue is fixed, this script can be replaced adding the following npm script: +# +# "ionic:serve": "gulp watch & NODE_OPTIONS=--max-old-space-size=4096 ng serve" +# + +# Run gulp watch. +echo "> gulp watch &" +gulp watch & + +# Remove unknown arguments and prepare angular target. +args=("$@") +angulartarget="serve" +total=${#args[@]} +for ((i=0; i NODE_OPTIONS=--max-old-space-size=4096 ng run app:$angulartarget ${args[@]}" +NODE_OPTIONS=--max-old-space-size=4096 ng run "app:$angulartarget" ${args[@]}