nx/docs/generated/packages/web/executors/file-server.json
Jack Hsu fcb6498e76
feat(web): allow additional http-server options to be passed from @nx/web:file-server (#26391)
This PR allows additional args such as `-d` (directory listing) and
`--mimetypes` to be passed from `serve` to the underlying `http-server`
module.

<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

## Current Behavior
<!-- This is the behavior we have today -->

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #22138
2024-06-05 13:08:42 -04:00

105 lines
4.3 KiB
JSON

{
"name": "file-server",
"implementation": "/packages/web/src/executors/file-server/file-server.impl.ts",
"schema": {
"version": 2,
"outputCapture": "direct-nodejs",
"title": "File Server",
"description": "Serve a web application from a folder. This executor is a wrapper around the [http-server](https://www.npmjs.com/package/http-server) package.",
"type": "object",
"cli": "nx",
"properties": {
"buildTarget": {
"type": "string",
"description": "Target which builds the application."
},
"parallel": {
"type": "boolean",
"description": "Build the target in parallel.",
"default": true
},
"maxParallel": {
"type": "number",
"description": "Max number of parallel jobs."
},
"port": {
"type": "number",
"description": "Port to listen on.",
"default": 4200
},
"host": {
"type": "string",
"description": "Host to listen on.",
"default": "localhost"
},
"ssl": {
"type": "boolean",
"description": "Serve using `HTTPS`.",
"default": false
},
"sslKey": {
"type": "string",
"description": "SSL key to use for serving `HTTPS`."
},
"sslCert": {
"type": "string",
"description": "SSL certificate to use for serving `HTTPS`."
},
"proxyUrl": {
"type": "string",
"description": "URL to proxy unhandled requests to. _Note: If the 'spa' flag is set to true, manually setting this value will override the catch-all redirect functionality from http-server which may lead to unexpected behavior._"
},
"proxyOptions": {
"type": "object",
"description": "Options for the proxy used by `http-server`.",
"default": {},
"properties": { "secure": { "type": "boolean", "default": false } },
"additionalProperties": true
},
"watch": {
"type": "boolean",
"description": "Watch for file changes.",
"default": true
},
"spa": {
"type": "boolean",
"description": "Redirect 404 errors to index.html (useful for SPA's)",
"default": false,
"x-priority": "important"
},
"staticFilePath": {
"type": "string",
"description": "Path where the build artifacts are located. If not provided then it will be infered from the buildTarget executor options as outputPath"
},
"cors": {
"type": "boolean",
"description": "Enable CORS",
"default": true
},
"gzip": {
"type": "boolean",
"description": "Enable gzip compression",
"default": false
},
"brotli": {
"type": "boolean",
"description": "Enable brotli compression",
"default": false
},
"cacheSeconds": {
"type": "number",
"description": "Set cache time (in seconds) for cache-control max-age header. To disable caching, use -1. Caching defaults to disabled.",
"default": -1
}
},
"additionalProperties": true,
"examplesFile": "---\ntitle: Examples for the Web file-server executor\ndescription: This page contains examples for the Vite @nx/web:file-server executor.\n---\n\n`project.json`:\n\n```json5\n\"myapp\": {\n \"targets\": {\n \"serve\": {\n \"executor\": \"@nx/web:file-server\",\n \"options\": {\n \"buildTarget\": \"build\",\n \"port\": 3000,\n },\n },\n \"build\": {\n \"outputs\": [\"{workspaceRoot}/dist/myapp\"],\n \"command\": \"echo 'Generating index.html' && mkdir -p dist && echo '<h1>Works</h1>' > dist/myapp/index.html\"\n },\n }\n}\n```\n\n```shell\nnx serve myapp\n```\n\n## Examples\n\n{% tabs %}\n{% tab label=\"Additional http-server options\" %}\n\nThere are additional options from `http-server` that can be passed as CLI args. For example, to enable directory listing, pass `-d` as follows:\n\n```shell\nnx serve myapp -d\n```\n\nRefer to the [`http-server`](https://www.npmjs.com/package/http-server) package for all available options.\n\n{% /tab %}\n{% /tabs %}\n",
"presets": []
},
"description": "Serve a web application from a folder.",
"aliases": [],
"hidden": false,
"path": "/packages/web/src/executors/file-server/schema.json",
"type": "executor"
}