fb-floChrome 扩展

联合创作 · 2023-09-22

fb-flo 是一个 Chrome 扩展,它可以让你不需要重载就能改变运行中的 APP。它很容易就能整合你建立的系统、dev 环境,并且能用于你最喜欢的编辑器上。

示例代码:

var flo = require('fb-flo'),
    path = require('path'),
    fs = require('fs');var server = flo(
  sourceDirToWatch,
  {
    port: 8888,
    host: 'localhost',
    verbose: false,
    glob: [       
      // All JS files in `sourceDirToWatch` and subdirectories
      '**/*.js',       
      // All CSS files in `sourceDirToWatch` and subdirectories
      '**/*.css'
    ]
  },  function resolver(filepath, callback) {    
    // 1. Call into your compiler / bundler.
    // 2. Assuming that `bundle.js` is your output file, update `bundle.js`
    //    and `bundle.css` when a JS or CSS file changes.
    callback({
      resourceURL: 'bundle' + path.extname(filepath),      
    // any string-ish value is acceptable. i.e. strings, Buffers etc.
      contents: fs.readFileSync(filepath),      
      update: function(_window, _resourceURL) {        
    // this function is executed in the browser, immediately after the resource has been updated with new content
    // perform additional steps here to reinitialize your application so it would take advantage of the new resource
        console.log("Resource " + _resourceURL + " has just been updated with new content");
      }
    });
  }
);
浏览 2
点赞
评论
收藏
分享

手机扫一扫分享

编辑
举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

编辑
举报