runBonjour.js 388 B

123456789101112131415161718192021
  1. 'use strict';
  2. function runBonjour({ port }) {
  3. const bonjour = require('bonjour')();
  4. const os = require('os');
  5. bonjour.publish({
  6. name: `Webpack Dev Server ${os.hostname()}:${port}`,
  7. port,
  8. type: 'http',
  9. subtypes: ['webpack'],
  10. });
  11. process.on('exit', () => {
  12. bonjour.unpublishAll(() => {
  13. bonjour.destroy();
  14. });
  15. });
  16. }
  17. module.exports = runBonjour;