2016-06-25 27 views
0

我使用Angular 2.我想禁用/刪除瀏覽器同步。但無法找到如何去做,或通過cmd或代碼?哪條路? 需要幫助)去哪裏禁用BrowserSync?路徑?文件?安慰? Angular 2

版角2.0.0 RC.1"

"Projest structure: 
-Build/ 
-NodeModules/ 
-SRC/ 
-Typings/ 
-gunlpfile.ts 
-bsconfig.json 
-tsconfig.json 
-tslint.json 
-typings.json" 

這是gulpfile.ts:

"use strict"; 

const gulp = require("gulp"); 
const del = require("del"); 
const sass = require('gulp-sass'); 
const tsc = require("gulp-typescript"); 
const sourcemaps = require('gulp-sourcemaps'); 
const tsProject = tsc.createProject("tsconfig.json"); 
const tslint = require('gulp-tslint'); 


gulp.task('clean', (cb) => { 
return del(["build"], cb); 
}); 

繼續

gulp.task('tslint',() => { 
return gulp.src("src/**/*.ts") 
    .pipe(tslint()) 
    .pipe(tslint.report('prose')); 
}); 


gulp.task("compile", ["tslint"],() => { 
let tsResult = gulp.src("src/**/*.ts") 
    .pipe(sourcemaps.init()) 
    .pipe(tsc(tsProject)) 
    .pipe(sourcemaps.write(".")) 
    .pipe(gulp.dest("build")); 
}); 


gulp.task("sass",() => { 
return gulp.src("src/**/*.{sass,scss}") 
.pipe(sourcemaps.init()) 
.pipe(sass().on('error', sass.logError)) 
.pipe(sourcemaps.write(".")) 
.pipe(gulp.dest("build")); 
}); 


gulp.task("resources",() => { 
return gulp.src(["src/**/*", "!**/*.{sass,scss,ts}"]) 
    .pipe(sourcemaps.write()) 
    .pipe(gulp.dest("build")); 
}); 

這是一部分gulpfile.ts

+0

只是簡單地刪除browserSync的代碼?你使用的是angular2 CLI嗎? –

+0

你可以添加更多信息嗎?你在哪裏使用它?版本,項目結構... [如何創建最小,完整和可驗證示例](http://stackoverflow.com/help/mcve) – Sasxa

+0

我是新手。什麼意思是CLI? whee刪除此代碼。說實話我搜索了每個gulp文件,但coudn't罰款任何BrowserSync變量 – Serhiy

回答

0

如果您使用Angular2-Seed項目,然後看看seed.config.ts

/** 
     * Configurations for NPM module configurations. Add to or override in project.config.ts. 
     * If you like, use the mergeObject() method to assist with this. 
     */ 
     PLUGIN_CONFIGS: any = { 
     /** 
     * The BrowserSync configuration of the application. 
     * The default open behavior is to open the browser. To prevent the browser from opening use the `--b` flag when 
     * running `npm start` (tested with serve.dev). 
     * Example: `npm start -- --b` 
     * @type {any} 
     */ 
     'browser-sync': { 
      middleware: [require('connect-history-api-fallback')({ index: `${this.APP_BASE}index.html` })], 
      port: this.PORT, 
      startPath: this.APP_BASE, 
      open: argv['b'] ? false : true, 
      injectChanges: false, 
      server: { 
      baseDir: `${this.DIST_DIR}/empty/`, 
      routes: { 
       [`${this.APP_BASE}${this.APP_DEST}`]: this.APP_DEST, 
       [`${this.APP_BASE}node_modules`]: 'node_modules', 
       [`${this.APP_BASE.replace(/\/$/, '')}`]: this.APP_DEST 
      } 
      } 
     } 
     }; 
+0

無法找到它。我不認爲我使用它。我寫了版本 – Serhiy