Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I'm currently working with a Vagrant/Virtualbox development environment. My web project is a django/Angularjs project where all front-end development scaffolding is done with brunch.

Brunch works fine when I use the brunch build command, but when I use the brunch watch command my javascript files are not processed by brunch when I make changes to the project on my host machine.

I've tried using nfs folder syncing config.vm.synced_folder folder["map"], folder["to"], type: folder["type"] ||= "nfs" and the default Virtualbox folder syncing but neither seems to work with brunch watch.

The following is my brunch-config.js file:

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',
    ]
  }
}
like image 400
user13653 Avatar asked Jan 23 '26 11:01

user13653


1 Answers

You probably need to enable polling-mode file watching in order to successfully detect changes across mounted file systems.

In your brunch-config:

watcher:
    usePolling: true

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

like image 59
es128 Avatar answered Jan 25 '26 08:01

es128



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!