diff --git a/lib/options.ts b/lib/options.ts index 0ce53419ab..b999dff2bc 100644 --- a/lib/options.ts +++ b/lib/options.ts @@ -36,7 +36,7 @@ export class Options extends commonOptionsLibPath.OptionsBase { bundle: { type: OptionType.Boolean }, all: { type: OptionType.Boolean }, teamId: { type: OptionType.String }, - syncAllFiles: { type: OptionType.Boolean, default: true }, + syncAllFiles: { type: OptionType.Boolean, default: false }, liveEdit: { type: OptionType.Boolean }, chrome: { type: OptionType.Boolean }, clean: { type: OptionType.Boolean }, diff --git a/lib/services/livesync/livesync-service.ts b/lib/services/livesync/livesync-service.ts index f1557f7e19..3e8830726f 100644 --- a/lib/services/livesync/livesync-service.ts +++ b/lib/services/livesync/livesync-service.ts @@ -2,6 +2,8 @@ import * as constants from "../../constants"; import * as helpers from "../../common/helpers"; import * as path from "path"; import * as semver from "semver"; +import { NodeModulesDependenciesBuilder } from "../../tools/node-modules/node-modules-dependencies-builder"; + let choki = require("chokidar"); class LiveSyncService implements ILiveSyncService { @@ -118,7 +120,19 @@ class LiveSyncService implements ILiveSyncService { private partialSync(syncWorkingDirectory: string, onChangedActions: ((event: string, filePath: string, dispatcher: IFutureDispatcher) => Promise)[]): void { let that = this; - let pattern = ["app", "package.json", "node_modules"]; + let dependenciesBuilder = this.$injector.resolve(NodeModulesDependenciesBuilder, {}); + let productionDependencies = dependenciesBuilder.getProductionDependencies(this.$projectData.projectDir); + let pattern = ["app"]; + + if (this.$options.syncAllFiles) { + pattern.push("package.json"); + + // watch only production node_module/packages same one prepare uses + for (let index in productionDependencies) { + pattern.push("node_modules/" + productionDependencies[index].name); + } + } + let watcher = choki.watch(pattern, { ignoreInitial: true, cwd: syncWorkingDirectory, ignored: '**/*.DS_Store' }).on("all", (event: string, filePath: string) => { that.$dispatcher.dispatch(async () => { try {