Z
Z
zeuss562017-06-20 22:35:01
Angular
zeuss56, 2017-06-20 22:35:01

How to rebuild only modified Angular 2 and Cordova files for live development?

Did the following:

cd Projects
ng new App
cd App
npm install nodemon --save-dev
cordova create cordova com.company.app "App"
cd cordova
cordova platform add browser

app/package.json:
{
  "name": "App",
  "version": "0.0.0",
  "scripts": {
    "ng:build": "ng build --target=production --environment=prod --output-path=cordova/www/",
    "build:browser": "npm run ng:build && cd cordova && cordova build browser",
    "build:android": "npm run ng:build && cd cordova && cordova build android",
    "dev:browser": "cd cordova && cordova run browser && nodemon --exec \"npm run ng:build\" -- ./src",
    "dev:android": "cd cordova && cordova run android && nodemon --exec \"npm run ng:build\" -- ./src"
  },
  "dependencies": {
    ...
  },
  "devDependencies": {
    ...
    "nodemon": "^1.11.0"
  }
}

Terminal again:
cd ..
npm run dev:browser

The output opens a browser with the application, but it is not a live preview. How to fix?
UPD: I solved the problem, but now with each change there is a long rebuild:
"ng:build": "ng build --target=production --environment=prod --output-path=cordova/www/",
"build:browser": "npm run ng:build && cd cordova && cordova build browser",
"build:android": "npm run ng:build && cd cordova && cordova build android",
"dev:browser": "nodemon --exec \"npm run ng:build && cd cordova && cordova run browser\"",
"dev:android": "nodemon --exec \"npm run ng:build && cd cordova && cordova run android\""

How to rebuild only changed files so as not to wait?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Z
zeuss56, 2017-06-30
@zeuss56

npm i -g @angular/cli cordova phonegap
cd %userprofile%\Documents\Projects
ng new App
cd App
cordova create cordova com.mycompany.appid "App"
cd cordova
cordova platform add browser
cd ..

{
  "name": "App",
  "version": "0.0.0",
  "scripts": {
    "start:ng:open": "ng serve --open",
    "start:ng:www": "ng serve --host 0.0.0.0 --public my.public.domain",
    "start:ng": "rmdir-cli cordova/www/ && ng build --output-path=cordova/www/ --watch",
    "start:cordova:serve": "cd cordova && mkdirp www && phonegap serve",
    "start:cordova:run": "cd cordova && mkdirp www && cordova run android",
    "start": "concurrently --kill-others \"npm run start:cordova:serve\" \"npm run start:ng\""
  },
  "devDependencies": {
    "concurrently": "^3.4.0",
    "rmdir-cli": "^2.0.6",
    "mkdirp": "^0.5.1",
    ...
  }
  ...
}

npm i
npm run start

O
ozknemoy, 2017-06-23
@ozknemoy

Recently, I prefer ready-made solutions from the git. i used ionic3-angular4 https://github.com/ionic-team/ionic2-app-base using command and package.json 'ionic serve -l'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question