Search code examples
nativescriptangular2-nativescriptnativescript-angularnativescript-plugin

angular-native-seed, Live sync is not working in windows 10


In my native script project, I have used angular-native-seed. Everything does work except Live sync. The same was raised in git hub under the issue list, still it does not resolve by anyone.

Whenever file change, gulp watch is called but failed to overwrite app folder from src folder (see the last comments in the below-mentioned url thread).

URL : enter link description here

Gulpfile.js

gulp.task('tns.Livesync', () => {
return gulp.watch([`../${SRC}**/*.common.ts`, `../${SRC}**/*.tns.ts`, `../${SRC}**/*.tns.html`,  `../${SRC}**/*.service.ts`,
 `../${SRC}**/*.tns.scss`, `../${SRC}**/*.scss`, `../${SRC}**/*.component.ts`, `../${SRC}**/*.routes.ts`,
 `../${SRC}**/*.index.ts`])
    .on('change', (file) => {
        var outputDest = file.substring(0, file.lastIndexOf('\\')+1).replace(SRC.substring(0, SRC.length - 1), DEST).replace('..\\', '');
        console.log('File-->' + file);
        console.log('Des-->' + outputDest);
        gulp.src([file])
            .pipe(rename(removeTns))
            .pipe(replace('.scss\'', '.css\'', { logs: { enabled: true }}))
            .pipe(debug({title: 'tns.Livesync'}))
            .pipe(debug({title: 'out ' + outputDest}))
            .pipe(gulp.dest(outputDest, {overwrite: true}));
    });

});

Anybody help me ?


Solution

  • This work for me:

    gulp.task('tns.Livesync', () => {
        return gulp.watch([`../${SRC}**/*.common.ts`, `../${SRC}**/*.tns.ts`, `../${SRC}**/*.tns.html`,  `../${SRC}**/*.service.ts`,
         `../${SRC}**/*.tns.scss`, `../${SRC}**/*.scss`, `../${SRC}**/*.component.ts`, `../${SRC}**/*.routes.ts`,
         `../${SRC}**/*.index.ts`])
            .on('change', (file) => {
                var outputDest = file.substring(0, file.lastIndexOf('\\')+1).replace('src\\', 'app\\').replace('..\\', '');
                gulp.src([file])
                    .pipe(rename((path) => { path.dirname = ''; }))
                    .pipe(rename(removeTns))
                    .pipe(replace('.scss\'', '.css\'', { logs: { enabled: true }}))
                    .pipe(debug({title: 'tns.Livesync'}))
                    .pipe(debug({title: 'out ' + outputDest}))
                    .pipe(gulp.dest(outputDest, {overwrite: true}));
            });
    });