# Server

# mix.serve()

mix.serve(handler: Function)

Manual start server for development. Reference watcher.

🌰 For example:

const balm = require('balm');

balm.config = {
  useDefaults: false // Required for `mix.serve()`
  // Other Options...
};

balm.go(mix => {
  mix.serve((watcher, reload) => {
    // Watch change files
    watcher.on('change', file => {
      console.log('changed', file);

      const extname = file.split('.')[1];
      if (extname === 'css') {
        mix.css(file, 'dist/css');
      }
      if (extname === 'js') {
        mix.js(`./${file}`, 'dist/js');
      }

      reload(); // Refresh browser
    });
  });
});
Last Updated: 11 days ago