2023-12-18 13:12:25 +08:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
function runBonjour({ port }) {
|
|
|
|
const bonjour = require('bonjour')();
|
2024-01-16 21:26:16 +08:00
|
|
|
const os = require('os');
|
2023-12-18 13:12:25 +08:00
|
|
|
|
|
|
|
bonjour.publish({
|
2024-01-16 21:26:16 +08:00
|
|
|
name: `Webpack Dev Server ${os.hostname()}:${port}`,
|
2023-12-18 13:12:25 +08:00
|
|
|
port,
|
|
|
|
type: 'http',
|
|
|
|
subtypes: ['webpack'],
|
|
|
|
});
|
|
|
|
|
|
|
|
process.on('exit', () => {
|
|
|
|
bonjour.unpublishAll(() => {
|
|
|
|
bonjour.destroy();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = runBonjour;
|