dev-info.js
592 Bytes
const fs = require('fs');
const path = require('path');
const info = {
host: '127.0.0.1',
port: 5001,
publicPath: 'http://127.0.0.1:5001'
};
try {
let dev = JSON.parse(fs.readFileSync(path.join(__dirname, '../../.devhost')));
info.host = dev.host;
info.publicPath = `http://${info.host}:${info.port}/`;
} catch (e) {
if (!process.env.NODE_ENV) {
console.error(e);
console.warn(`
推荐在项目主目录建一个 .devhost 文件,内容为
{
"host": "127.0.0.1"
}
`);
}
}
module.exports = info;