Brunch watch 在 运行 in Vagrant/Virtualbox 时不处理后续更改的文件

Brunch watch does not process files on subsequent changes while running in Vagrant/Virtualbox

我目前正在使用 Vagrant/Virtualbox 开发环境。我的 web 项目是一个 django/Angularjs 项目,所有前端开发脚手架都是用 brunch 完成的。

当我使用 brunch build 命令时,Brunch 工作正常,但是当我使用 brunch watch 命令时,当我对项目进行更改时,我的 javascript 文件不会被 brunch 处理我的主机。

我试过使用 nfs 文件夹同步 config.vm.synced_folder folder["map"], folder["to"], type: folder["type"] ||= "nfs" 和默认的 Virtualbox 文件夹同步,但似乎都不适用于 brunch watch

以下是我的brunch-config.js档案:

exports.config = {
  paths: {
    watched: [
      'app',
      'assets',
      'styles',
      'vendor',
    ]
  },
  files: {
    javascripts: {
      joinTo: {
        'javascript/app.js': /^app/,
        'javascript/vendor.js': /^(vendor|bower_components)/,
      }
    },
    stylesheets: {
      joinTo: {
        'styles/app.css': /^styles/,
        'styles/vendor.css': /^(vendor|bower_components)/,
      }
    }
  },
  conventions: {
    assets: function(path) {
      /**
       * Loops every path and returns path|true|false according what we need
       * @param   path    file or directory's path
       * @returns path    if it is a directory
       *          true    if it fit with the regular expression
       *          false   otherwise
       *
       */
      if( /\/$/.test(path) ) return path;
      // /^app\/.*\.html/.test(path) ||
      // RegExp for anything we need
      return /assets[\/]/.test(path) 
            || /.*(?:\.eot|\.svg|\.ttf|\.woff2|\.woff)/.test(path); 
    }
  },
  plugins: {
    afterBrunch: [
      'mv public/bootstrap/dist/fonts/* public/fonts',
      'rm -r public/bootstrap',
      'mv public/bootstrap-material-design/dist/fonts/* public/fonts/',
      'rm -r public/bootstrap-material-design',
    ]
  }
}

您可能需要启用轮询模式文件监视才能成功检测已安装文件系统的更改。

在您的早午餐配置中:

watcher:
    usePolling: true

https://github.com/brunch/brunch/blob/01afa693548d0dad2ade6528cedd20f0fbf8f2ac/docs/config.md#watcher