Watch Changes in NPM Repository

Hi all,

I have a NPM repository that I am working on for my Ionic2 application, I have this linked into my main project with npm link.

This works fine, except that when changes are made to this repository they are not noticed by the live reload, and thus I have to exit my ionic serve, run npm install and restart the service.

Is there a way to extend what Ionic is watching for file changes so that changes in the NPM repository are detected and picked up ?

You have to override ionic_watch. Here how you can.

Add these lines in package.json:

  "config": {
    "ionic_watch": "config/watch.config.js"
  }

Then copy node/modules/@ionic/app-scripts/config/watch.config.js in config/watch.config.js.

Finally change first lines and the srcFiles.paths field. Here edited watch.config.js:

var watch = require('@ionic/app-scripts/dist/watch.js');
var copy = require('@ionic/app-scripts/dist/copy');
var copyConfig = require('@ionic/app-scripts/config/copy.config.js');

module.exports = {
    srcFiles: {
        paths: ['{{SRC}}/**/*.(ts|html|s(c|a)ss)', '../shared/dist/**/*.(js|html|css)'],
        options: { ignored: ['{{SRC}}/**/*.spec.ts', '{{SRC}}/**/*.e2e.ts', '**/*.DS_Store'] },
        callback: watch.buildUpdate
    },
    copyConfig: copy.copyConfigToWatchConfig()
};