Blame view

public/build/dev-info.js 592 Bytes
ccbikai(👎🏻🍜) authored
1 2 3 4 5 6 7 8 9 10 11 12 13
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;
14
    info.publicPath = `http://${info.host}:${info.port}/`;
ccbikai(👎🏻🍜) authored
15
} catch (e) {
16 17 18 19 20 21 22 23
    if (!process.env.NODE_ENV) {
        console.error(e);
        console.warn(`
        推荐在项目主目录建一个 .devhost 文件,内容为
        {
            "host": "127.0.0.1"
        }
        `);
ccbikai(👎🏻🍜) authored
24 25 26 27
    }
}

module.exports = info;