3

私はhttps://github.com/PolymerElements/generator-polymer-init-custom-buildポリマーカスタムビルドのgulpfileにbrowser-syncを入れる正しい場所はどこですか?

最新のを使用してPolymer custom-build gulpfile.js

にBrowsersyncを追加したいが、ポリマーのカスタムビルドのgulpfile.jsでそれのための適切な場所がどこにあるか私は理解できませんよ

カスタムビルドのgulpfile.jsにBrowsersyncを組み込む方法の例を挙げてください。

+1

この作業を取得上の任意の運?私は以下の答えを使用したくない。というのも、それはたくさんのエキストラを含んでいるからだ。彼がリンクしているリポジトリは失敗しているようだ。私の目標は、シンプルなままにして、ブラウザ同期をカスタムビルドに追加することです。 – 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がアサーションエラーを投げている 'タスク関数を指定する必要があります' - なぜですか? –

関連する問題