nx/packages/vite/docs/dev-server-examples.md
2023-02-01 21:53:19 +02:00

1.7 KiB

title description
Examples for the Vite dev server executor This page contains examples for the Vite @nrwl/vite:dev-server executor.

project.json:

//...
"my-app": {
    "targets": {
        //...
        "serve": {
            "executor": "@nrwl/vite:dev-server",
            "defaultConfiguration": "development",
            "options": {
                "buildTarget": "my-app:build",
            },
            "configurations": {
                ...
            }
        },
    }
}
nx serve my-app

Examples

{% tabs %} {% tab label="Set up a custom port" %}

You can always set the port in your vite.config.ts file. However, you can also set it directly in your project.json file, in the serve target options:

//...
"my-app": {
    "targets": {
        //...
        "serve": {
            "executor": "@nrwl/vite:dev-server",
            "defaultConfiguration": "development",
            "options": {
                "buildTarget": "my-app:build",
                "port": 4200,
            },
            "configurations": {
                ...
            }
        },
    }
}

{% /tab %} {% tab label="Specify a proxyConfig" %}

You can specify a proxy config by pointing to the path of your proxy configuration file:

//...
"my-app": {
    "targets": {
        //...
        "serve": {
            "executor": "@nrwl/vite:dev-server",
            "defaultConfiguration": "development",
            "options": {
                "buildTarget": "my-app:build",
                "proxyConfig": "apps/my-app/proxy.conf.json"
            },
            "configurations": {
                ...
            }
        },
    }
}

{% /tab %}

{% /tabs %}