@pega/constellation-dx-components-build-utils
Version:
This tool uses a 'v3' approach to group components in a library, create a component map, employ webpack, and load the library like Pega-generated components, constellation app-static.
40 lines (32 loc) • 1.55 kB
JavaScript
const fs = require('fs');
const path = require('path');
const {buildComponentsListFile, buildComponentMapJsFile} = require('../build/build');
const CONSTANTS = require('../constant');
const child_process = require("child_process");
const helper = require('../helper');
const devServerStart = async(libraryName, libraryVersion, port) => {
const { buildFolderFullPath, buildFolderName, packageVersion } = helper.getBuildFolderName(libraryName, libraryVersion);
buildComponentsListFile(buildFolderName, packageVersion, true);
buildComponentMapJsFile(buildFolderFullPath);
const webpackPath = path.join(CONSTANTS.BUILD_TOOL_ROOT_PATH).replace(/\\/g, '/');
const projectPath = path.join(CONSTANTS.CURRENT_WORKING_DIR, CONSTANTS.PROJECT_ROOT).replace(/\\/g, '/');
if(!port){
port = 3030;
}
child_process.execSync(`npx webpack serve --mode=development --env mode=development buildFolderFullPath=${buildFolderFullPath} v3=false port=${port} --config ${webpackPath}/webpack.config.js`, {
stdio: [0, 1, 2],
cwd: path.join(CONSTANTS.CURRENT_WORKING_DIR).replace(/\\/g, '/'),
});
fs.unlink(path.join(projectPath, CONSTANTS.COMPONENT_LIST_FILE_NAME_OUTPUT).replace(/\\/g, '/'), (err) => {
if (err) throw err;
});
fs.unlink(path.join(projectPath, CONSTANTS.COMPONENT_LIST_FILE_NAME).replace(/\\/g, '/'), (err) => {
if (err) throw err;
});
fs.unlink(path.join(projectPath, CONSTANTS.ENTRY_POINT_FILE).replace(/\\/g, '/'), (err) => {
if (err) throw err;
});
}
module.exports = {
devServerStart
}