burdy
Version:
Open Source Headless Platform
36 lines (35 loc) • 2.25 kB
JavaScript
;
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 rimraf_1 = __importDefault(require("rimraf"));
const webpack_1 = __importDefault(require("webpack"));
const path_util_1 = __importDefault(require("./util/path.util"));
const webpack_util_1 = require("./util/webpack.util");
const config_1 = __importDefault(require("../shared/features/config"));
const webpack_config_1 = require("../webpack.config");
const scriptDbActions = (action) => __awaiter(void 0, void 0, void 0, function* () {
var _a;
const buildDirectory = path_util_1.default.cache('db-actions');
yield (0, rimraf_1.default)(buildDirectory, (error) => error && console.log(error));
const webpackServerConfig = (0, webpack_config_1.webpackServerConfigure)((webpackConfig) => {
webpackConfig.entry = path_util_1.default.root('scripts', 'entry', 'db-actions');
webpackConfig.devtool = false;
webpackConfig.output.path = buildDirectory;
webpackConfig.plugins.push(new webpack_1.default.DefinePlugin({ action: JSON.stringify(action) }));
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.server);
const serverCompiler = (0, webpack_1.default)(webpackServerConfig);
yield (0, webpack_util_1.compilerRun)(serverCompiler);
});
exports.default = scriptDbActions;