devtools.js 498 Bytes
const fs = require('fs');
const url = require('url');
let devTool = {
    devHost: '127.0.0.1',
    port: 5001
};

try {
    let dev = fs.readFileSync('.devhost');

    dev = JSON.parse(dev.toString());

    if (dev.publicPath) {
        let urlObj = url.parse(dev.publicPath);

        devTool = {
            devHost: urlObj.hostname,
            port: urlObj.port
        };
    } else {
        devTool.devHost = dev.host;
    }
} catch (e) {} // eslint-disable-line

module.exports = devTool;