3

나는 https://github.com/PolymerElements/generator-polymer-init-custom-build폴리머 맞춤형 빌드의 gulpfile에 browser-sync를 넣을 수있는 적절한 위치는 어디입니까?

최신을 사용하고 Polymer custom-build gulpfile.js

에 Browsersync을 추가 할하지만 폴리머 맞춤 빌드의 gulpfile.js에 대한 적절한 장소가 어디 있는지 나는 이해할 수있어

Browsersync를 custom-build의 gulpfile.js에 통합하는 방법에 대한 예제를 제공해 주시겠습니까?

+1

이 작업을 얻기에 어떤 행운이? 나는 많은 엑스트라를 포함하고 있기 때문에 그가 링크하고있는 repo가 ​​실패하고있는 것처럼 보이기 때문에 아래의 답을 사용하고 싶지 않습니다. 내 목표는 간단하게 유지하고 사용자 정의 빌드에 브라우저 동기화 만 추가하는 것입니다. – Oneezy

+1

gulp 파일을 다음과 같이 변경했습니다. https://gist.github.com/edvail/4c0ffb1d76c86808cd3d7b467b0e7ab5 –

+0

감사합니다! 나는 그것을 줄 것이다 – Oneezy

답변

1

발전기를 사용하여 https://github.com/seaneking/generator-polymer-element에서 종료되었습니다.

이 내 작업 gulpfile.js입니다 :

https://jsfiddle.net/svantetobias/qqwcrwcf/1/ 내가 여기에 중요한 부분이라고 생각 :

// Core deps 
// Using require() because of rollup babel preset 
const gulp = require('gulp'); 
const gulprun = require('run-sequence'); 
const browserSync = require('browser-sync'); 
const bs = browserSync.create() 
const OPTIONS = { 
    browserSync: { 
     server: { 
     baseDir: './', 
     index: 'demo/index.html', 
     routes: { 
      '/': './bower_components' 
     } 
     }, 
     open: false, // Don't open browser on reload 
     notify: true // Show notifications in the browser. 
    } 
    }; 

gulp.task('build',() => { 
    // Build stuff... 
}); 

gulp.task('serve', (callback) => bs.init(OPTIONS.browserSync)); 
gulp.task('refresh',() => bs.reload()); 
gulp.task('watch',() => gulp.watch(['src/**/*'],() => gulprun('build', 'refresh'))); 
gulp.task('default', ['build', 'serve', 'watch']); 
+0

anwer가 단언 오류를 던지고 있습니다. '작업 기능을 지정해야합니다.'- 왜? –