首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在聚合物自定义构建的gulpfile中放置浏览器同步的正确位置在哪里?

在聚合物自定义构建的gulpfile中放置浏览器同步的正确位置在哪里?
EN

Stack Overflow用户
提问于 2016-09-08 15:41:08
回答 1查看 288关注 0票数 3

我正在使用最新的https://github.com/PolymerElements/generator-polymer-init-custom-build

并希望将浏览器同步添加到Polymer custom-build gulpfile.js

但我不明白在聚合物定制的gulpfile.js中哪里才是合适的位置

您能提供一个如何将浏览器同步整合到定制构建的gulpfile.js中的示例吗?

EN

回答 1

Stack Overflow用户

发布于 2016-09-08 17:06:29

我最终使用了https://github.com/seaneking/generator-polymer-element的生成器。

这是我的工作gulpfile.js:https://jsfiddle.net/svantetobias/qqwcrwcf/1/

我认为这里的关键部分是:

代码语言:javascript
复制
// 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']);
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39385210

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档