UNPKG

@lynx-js/rspeedy

Version:

A webpack/rspack-based frontend toolchain for Lynx

75 lines (74 loc) 5.2 kB
import * as __rspack_external_node_path_c5b9b54f from "node:path"; export const __rspack_esm_id = "src_cli_commands_ts"; export const __rspack_esm_ids = [ "src_cli_commands_ts" ]; export const __webpack_modules__ = { "./src/cli/commands.ts" (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { apply: ()=>apply }); var node_path__rspack_import_0 = __webpack_require__("node:path"); var _version_js__rspack_import_1 = __webpack_require__("./src/version.ts"); function applyCommonOptions(command) { command.option('-c --config <config>', 'specify the configuration file, can be a relative or absolute path').option('--env-mode <mode>', 'specify the env mode to load the .env.[mode] file').option('--no-env', 'disable loading `.env` files"').option('-m --mode <mode>', 'specify the build mode, can be `development`, `production` or `none`').option('-r --root <root>', 'set the project root directory (absolute path or relative to cwd)'); } function resolveRoot(cwd, root) { if (!root) return cwd; return node_path__rspack_import_0["default"].isAbsolute(root) ? root : node_path__rspack_import_0["default"].resolve(cwd, root); } function apply(program) { const cwd = process.cwd(); program.name('rspeedy').usage('<command> [options]').version(_version_js__rspack_import_1.version).option('--unmanaged', 'Force to use the unmanaged version of Rspeedy, instead of the locally installed.').showHelpAfterError(true).showSuggestionAfterError(true).exitOverride(); const buildCommand = program.command('build'); buildCommand.description('Build the project in production mode').option('--environment <name...>', 'specify the name of environment to build').option('--watch', 'Enable watch mode to automatically rebuild on file changes').action(async (buildOptions)=>{ const actualRoot = resolveRoot(cwd, buildOptions.root); const { build } = await __webpack_require__.e("src_cli_build_ts").then(__webpack_require__.bind(__webpack_require__, "./src/cli/build.ts")); return await build.call(buildCommand, actualRoot, buildOptions); }); const devCommand = program.command('dev'); devCommand.description('Run the dev server and watch for source file changes while serving.').option('--base <base>', 'specify the base path of the server').option('--environment <name...>', 'specify the name of environment to build').action(async (devOptions)=>{ const actualRoot = resolveRoot(cwd, devOptions.root); const { dev } = await __webpack_require__.e("src_cli_dev_ts").then(__webpack_require__.bind(__webpack_require__, "./src/cli/dev.ts")); return await dev.call(devCommand, actualRoot, devOptions); }); const inspectCommand = program.command('inspect'); inspectCommand.description('View the Rsbuild config and Rspack config of the project.').option('--output <output>', 'specify inspect content output path').option('--verbose', 'show full function definitions in output').action(async (inspectOptions)=>{ const actualRoot = resolveRoot(cwd, inspectOptions.root); const { inspect } = await __webpack_require__.e("src_cli_inspect_ts").then(__webpack_require__.bind(__webpack_require__, "./src/cli/inspect.ts")); return await inspect.call(inspectCommand, actualRoot, inspectOptions); }); const previewCommand = program.command('preview'); previewCommand.description('Preview the production build outputs locally.').option('--base <base>', 'specify the base path of the server').action(async (previewOptions)=>{ const actualRoot = resolveRoot(cwd, previewOptions.root); const { preview } = await __webpack_require__.e("src_cli_preview_ts").then(__webpack_require__.bind(__webpack_require__, "./src/cli/preview.ts")); return await preview.call(previewCommand, actualRoot, previewOptions); }); const commonCommands = [ devCommand, buildCommand, inspectCommand, previewCommand ]; commonCommands.forEach((command)=>applyCommonOptions(command)); return program; } }, "./src/version.ts" (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { version: ()=>version, rspackVersion: ()=>rspackVersion, rsbuildVersion: ()=>core_.version }); var core_ = __webpack_require__("@rsbuild/core"); var package_namespaceObject = { rE: "0.12.4" }; const version = package_namespaceObject.rE; const rspackVersion = core_.rspack.rspackVersion; }, "node:path" (module) { module.exports = __rspack_external_node_path_c5b9b54f; } };