I have an Ionic project and I use external tool for processing Coffee and SCSS. By default livereload in Ionic project watches everything. Where I can change this?
2 Answers
This setting is named watchPatterns
(source) and can be changed in ionic.project
file:
{
...
"watchPatterns": ["www/**/*", "!www/lib/**/*", "!www/config.codekit", "!www/**/*.scss", "!www/**/*.coffee"]
}
Default value: ["www/**/*", "!www/lib/**/*"]
I just wanted to give an update as the accepted answer does not work for the newer version of Ionic CLI.
For Ionic CLI v3.1.2 & Ionic Framework v1.3.3:
Versions:
Ionic CLI : 3.1.2
Ionic Framework : ionic1 1.3.3
@ionic/cli-utils : 1.1.2
@ionic/cli-plugin-ionic1 : 1.1.2
The "watch pattern" for livereload is not configurable from your project files. You have to change WATCH_PATTERNS
in the source code itself.
If you've built your Ionic v1 app using the tabs starter app (doc):
Example:ionic start myApp tabs --type ionic1
The file you will need to change is in the directory ./myApp/node_modules/@ionic/cli-plugin-ionic1/dist/serve/config.js
Below is what the file will look like:
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const path = require("path");
exports.WATCH_PATTERNS = [
'scss/**/*',
'www/**/*',
'!www/lib/**/*',
'!www/**/*.map'
];
exports.LOGGER_DIR = '__ion-dev-server';
exports.IONIC_LAB_URL = '/ionic-lab';
exports.DEFAULT_ADDRESS = '0.0.0.0';
exports.DEFAULT_LIVERELOAD_PORT = 35729;
exports.DEFAULT_SERVER_PORT = 8100;
exports.IOS_PLATFORM_PATH = path.join('platforms', 'ios', 'www');
exports.ANDROID_PLATFORM_PATH = path.join('platforms', 'android', 'assets', 'www');
From there you can modify the WATCH_PATTERNS
array to watch or '!' not watch a particular directory or file.
This isn't an ideal solution since the starter app uses the Node Package Manager (NPM) to manage the @ionic/cli-plugin-ionic1
dependency. If you decide to run this project on another computer or update your node modules, then you would have to re-do the steps above to customize the watch patterns. However, you can fork the source code and tell NPM to use your version instead.
-
I use livereload on port 35729 and want to only livereload two folders
public
andassets
, the rest not. is it possible?– TimoMay 13, 2021 at 14:51