diff --git a/docs/generated/packages/web/executors/file-server.json b/docs/generated/packages/web/executors/file-server.json index ecb1a5e1f80fb..9b1db57f2d354 100644 --- a/docs/generated/packages/web/executors/file-server.json +++ b/docs/generated/packages/web/executors/file-server.json @@ -75,6 +75,21 @@ "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": false, diff --git a/packages/web/src/executors/file-server/file-server.impl.ts b/packages/web/src/executors/file-server/file-server.impl.ts index 4ba44ce844a31..b998060c392d9 100644 --- a/packages/web/src/executors/file-server/file-server.impl.ts +++ b/packages/web/src/executors/file-server/file-server.impl.ts @@ -19,7 +19,7 @@ import { readModulePackageJson } from 'nx/src/utils/package-json'; const pmCmd = platform() === 'win32' ? `npx.cmd` : 'npx'; function getHttpServerArgs(options: Schema) { - const args = ['-c-1']; + const args = [`-c${options.cacheSeconds}`]; if (options.cors) { args.push(`--cors`); @@ -43,6 +43,12 @@ function getHttpServerArgs(options: Schema) { if (options.proxyUrl) { args.push(`-P=${options.proxyUrl}`); } + if (options.gzip) { + args.push('-g'); + } + if (options.brotli) { + args.push('-b'); + } if (options.proxyOptions) { Object.keys(options.proxyOptions).forEach((key) => { diff --git a/packages/web/src/executors/file-server/schema.d.ts b/packages/web/src/executors/file-server/schema.d.ts index dc383296765e4..5eab1b439817e 100644 --- a/packages/web/src/executors/file-server/schema.d.ts +++ b/packages/web/src/executors/file-server/schema.d.ts @@ -14,4 +14,7 @@ export interface Schema { spa: boolean; staticFilePath?: string; cors?: boolean; + gzip?: boolean; + brotli?: boolean; + cacheSeconds?: number; } diff --git a/packages/web/src/executors/file-server/schema.json b/packages/web/src/executors/file-server/schema.json index 2a049e2fd0a16..e4d0d6bdff3c3 100644 --- a/packages/web/src/executors/file-server/schema.json +++ b/packages/web/src/executors/file-server/schema.json @@ -77,6 +77,21 @@ "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": false,