UNPKG

burdy

Version:

Open Source Headless Platform

50 lines (49 loc) 2.68 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const path_util_1 = __importDefault(require("./util/path.util")); const config_1 = __importDefault(require("../shared/features/config")); const webpack_1 = __importDefault(require("webpack")); const webpack_shell_plugin_next_1 = __importDefault(require("webpack-shell-plugin-next")); const express_1 = __importDefault(require("express")); const webpack_util_1 = require("./util/webpack.util"); const webpack_config_1 = require("../webpack.config"); const scriptDev = () => __awaiter(void 0, void 0, void 0, function* () { var _a; const webpackServerConfig = (0, webpack_config_1.webpackServerConfigure)((webpackConfig) => { webpackConfig.entry = path_util_1.default.root('scripts', 'entry', 'dev'); webpackConfig.output.path = path_util_1.default.devBuild(); webpackConfig.plugins.push(new webpack_shell_plugin_next_1.default({ onBuildEnd: { scripts: [ `cross-env ADMIN_PATH="${path_util_1.default.admin()}" nodemon -q --watch ${path_util_1.default.devBuild()} ${path_util_1.default.devBuild('main')}`, ], parallel: true, blocking: false, }, })); return webpackConfig; }, (_a = config_1.default === null || config_1.default === void 0 ? void 0 : config_1.default.webpack) === null || _a === void 0 ? void 0 : _a.admin); const compiler = (0, webpack_1.default)(webpackServerConfig); compiler.watch({ aggregateTimeout: 300, }, () => { }); const app = (0, express_1.default)(); yield (0, webpack_util_1.attachWebpackMiddleware)(app); app.listen(process.env.ADMIN_PORT).on('error', (e) => { console.log(e); console.log('error occurred'); }); }); exports.default = scriptDev;