【问题标题】:angular-native-seed, Live sync is not working in windows 10角原生种子,实时同步在 Windows 10 中不起作用
【发布时间】:2018-09-26 17:35:59
【问题描述】:

在我的原生脚本项目中,我使用了 angular-native-seed。除实时同步外,一切正常。在问题列表下的 git hub 中提出了同样的问题,但仍然没有人解决。

每当文件更改时,都会调用 gulp watch,但无法从 src 文件夹覆盖 app 文件夹(请参阅下面提到的 url 线程中的最后一个 cmets)。

网址: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}));
    });

});

有人帮帮我吗?

【问题讨论】:

    标签: nativescript angular2-nativescript nativescript-angular nativescript-plugin


    【解决方案1】:

    这对我有用:

    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}));
            });
    });
    

    【讨论】:

    • 如果您使用的是angular-native-seed,请确保同时运行任务npm run livesync
    • 这有效,但仅限于第一次实时同步。当它再次运行时,css 丢失了。
    猜你喜欢
    • 1970-01-01
    • 2017-11-18
    • 1970-01-01
    • 2016-03-08
    • 2018-12-04
    • 2015-12-12
    • 2018-12-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多