UNPKG

server-renderer

Version:

library of server side render for React

26 lines (25 loc) 906 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const path_1 = tslib_1.__importDefault(require("path")); const fs_1 = tslib_1.__importDefault(require("fs")); const chalk_1 = tslib_1.__importDefault(require("chalk")); const child_process_1 = require("child_process"); const config_1 = require("../config/config"); const config = config_1.getConfig(); const chunkPath = path_1.default.join(config.distDir, 'server/app.js'); function start() { if (fs_1.default.existsSync(chunkPath)) { const childProcess = child_process_1.fork(chunkPath, [], { stdio: 'inherit' }); childProcess.on('close', (code) => { if (code !== 0) { // error happened! start(); } }); } else { console.log(chalk_1.default.red(`"${chunkPath}" is not exist`)); } } start();