-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
4 changed files
with
81 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
--- | ||
title: Examples for the Web file-server executor | ||
description: This page contains examples for the Vite @nx/web:file-server executor. | ||
--- | ||
|
||
`project.json`: | ||
|
||
```json5 | ||
"myapp": { | ||
"targets": { | ||
"serve": { | ||
"executor": "@nx/web:file-server", | ||
"options": { | ||
"buildTarget": "build", | ||
"port": 3000, | ||
}, | ||
}, | ||
"build": { | ||
"outputs": ["{workspaceRoot}/dist/myapp"], | ||
"command": "echo 'Generating index.html' && mkdir -p dist && echo '<h1>Works</h1>' > dist/myapp/index.html" | ||
}, | ||
} | ||
} | ||
``` | ||
|
||
```shell | ||
nx serve myapp | ||
``` | ||
|
||
## Examples | ||
|
||
{% tabs %} | ||
{% tab label="Additional http-server options" %} | ||
|
||
There are additional options from `http-server` that can be passed as CLI args. For example, to enable directory listing, pass `-d` as follows: | ||
|
||
```shell | ||
nx serve myapp -d | ||
``` | ||
|
||
Refer to the [`http-server`](https://www.npmjs.com/package/http-server) package for all available options. | ||
|
||
{% /tab %} | ||
{% /tabs %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters