### Starts the server with cache reset Source: https://github.com/nrwl/nx/blob/master/packages/react-native/docs/start-examples.md Example of configuring the start target to reset the cache. ```json "start": { "executor": "@nx/react-native:start", "options": { "port": 8081, "resetCache": true } } ``` -------------------------------- ### Default project.json configuration for start Source: https://github.com/nrwl/nx/blob/master/packages/react-native/docs/start-examples.md This shows the default configuration for the start target in a project.json file. ```json { "name": "mobile", //... "targets": { //... "start": { "executor": "@nx/react-native:start", "options": { "port": 8081 } } } } ``` -------------------------------- ### Convert to Host Source: https://github.com/nrwl/nx/blob/master/packages/angular/docs/setup-mf-examples.md Converts an existing application to a host application. ```bash nx g setup-mf myapp --mfType=host --routing=true ``` -------------------------------- ### Convert to Remote Source: https://github.com/nrwl/nx/blob/master/packages/angular/docs/setup-mf-examples.md Converts an existing application to a remote application. ```bash nx g setup-mf myapp --mfType=remote --routing=true ``` -------------------------------- ### Start on web platform Source: https://github.com/nrwl/nx/blob/master/packages/expo/docs/start-examples.md Configuration to start the Expo application in a web browser. ```json "start": { "executor": "@nx/expo:start", "options": { "port": 8081, "web": true } } ``` -------------------------------- ### Basic project.json configuration for start target Source: https://github.com/nrwl/nx/blob/master/packages/expo/docs/start-examples.md This snippet shows the basic configuration for the 'start' target in a project.json file for an Nx Expo project. ```json { "name": "mobile", //... "targets": { //... "start": { "executor": "@nx/expo:start", "options": { "port": 8081 } } //... } } ``` -------------------------------- ### Command to start on web platform Source: https://github.com/nrwl/nx/blob/master/packages/expo/docs/start-examples.md Command-line argument to start the Expo application in a web browser. ```shell nx start --web ``` -------------------------------- ### Convert to Host and attach to existing remote applications Source: https://github.com/nrwl/nx/blob/master/packages/angular/docs/setup-mf-examples.md Converts an existing application to a host application and attaches existing remote applications. ```bash nx g setup-mf myapp --mfType=host --routing=true --remotes=remote1,remote2 ``` -------------------------------- ### Starts the server non-interactively Source: https://github.com/nrwl/nx/blob/master/packages/react-native/docs/start-examples.md Example of configuring the start target to run in non-interactive mode. ```json "start": { "executor": "@nx/react-native:start", "options": { "port": 8081, "interactive": false } } ``` -------------------------------- ### Command to start on iOS platform Source: https://github.com/nrwl/nx/blob/master/packages/expo/docs/start-examples.md Command-line argument to start the Expo application on an iOS simulator. ```shell nx start --ios ``` -------------------------------- ### Convert to Remote and attach to a host application Source: https://github.com/nrwl/nx/blob/master/packages/angular/docs/setup-mf-examples.md Converts an existing application to a remote application and attaches it to an existing host application. ```bash nx g setup-mf myapp --mfType=remote --routing=true --host=myhostapp ``` -------------------------------- ### Add Nx to Existing Repository Source: https://github.com/nrwl/nx/blob/master/scripts/readme-fragments/content.md Command to add Nx to an existing repository. ```bash npx nx@latest init ``` -------------------------------- ### Before Source: https://github.com/nrwl/nx/blob/master/packages/jest/src/migrations/update-23-0-0/update-snapshot-guide-link.md Example of a .snap file with the legacy snapshot guide link. ```text // Jest Snapshot v1, https://goo.gl/fbAQLP exports[``renders correctly 1``] = ``"hello"``; ``` -------------------------------- ### Serve command Source: https://github.com/nrwl/nx/blob/master/packages/web/docs/file-server-examples.md This shell command starts the file server for the 'myapp' project. ```shell nx serve myapp ``` -------------------------------- ### Create Nx Workspace with npm init Source: https://github.com/nrwl/nx/blob/master/scripts/readme-fragments/content.md Command to create a new Nx workspace using npm init. ```bash npm init nx-workspace ``` -------------------------------- ### Command to start on Android platform Source: https://github.com/nrwl/nx/blob/master/packages/expo/docs/start-examples.md Command-line argument to start the Expo application on a connected Android device. ```shell nx start --android ``` -------------------------------- ### After Source: https://github.com/nrwl/nx/blob/master/packages/jest/src/migrations/update-23-0-0/update-snapshot-guide-link.md Example of a .snap file with the updated snapshot guide link. ```text // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[``renders correctly 1``] = ``"hello"``; ``` -------------------------------- ### Command to run the start target Source: https://github.com/nrwl/nx/blob/master/packages/expo/docs/start-examples.md This snippet shows the shell command to execute the 'start' target for a specific Nx project. ```shell nx run mobile:start ``` -------------------------------- ### Install Cypress Component Testing Source: https://github.com/nrwl/nx/blob/master/packages/react/docs/cypress-component-configuration-examples.md Command to generate Cypress component testing configuration for a React project. ```shell nx g @nx/react:cypress-component-configuration --project=my-cool-react-project ``` -------------------------------- ### Start on iOS platform Source: https://github.com/nrwl/nx/blob/master/packages/expo/docs/start-examples.md Configuration to start the Expo application on an iOS simulator. ```json "start": { "executor": "@nx/expo:start", "options": { "port": 8081, "ios": true } } ``` -------------------------------- ### Simple Application Source: https://github.com/nrwl/nx/blob/master/packages/react/docs/application-examples.md Create a basic React application named 'my-app'. ```bash nx g @nx/react:application apps/my-app ``` -------------------------------- ### Application using Vite as bundler Source: https://github.com/nrwl/nx/blob/master/packages/web/docs/application-examples.md Create an application named `my-app` using Vite as the bundler. ```bash nx g @nx/web:app apps/my-app --bundler=vite ``` -------------------------------- ### Start on Android platform Source: https://github.com/nrwl/nx/blob/master/packages/expo/docs/start-examples.md Configuration to start the Expo application on a connected Android device. ```json "start": { "executor": "@nx/expo:start", "options": { "port": 8081, "android": true } } ``` -------------------------------- ### List Available Emulators Source: https://github.com/nrwl/nx/blob/master/packages/react-native/docs/run-android-examples.md Command to list all available Android Virtual Devices (AVDs). ```bash emulator -list-avds ``` -------------------------------- ### Running the serve target Source: https://github.com/nrwl/nx/blob/master/packages/js/docs/node-examples.md Command to run the 'serve' target for 'my-app' using Nx. ```bash npx nx serve my-app ``` -------------------------------- ### Reset cache when starting the server Source: https://github.com/nrwl/nx/blob/master/packages/expo/docs/start-examples.md Configuration to clear the Metro bundler cache when starting the Expo application. ```json "start": { "executor": "@nx/expo:start", "options": { "port": 8081, "clear": true } } ``` -------------------------------- ### Project Configuration Source: https://github.com/nrwl/nx/blob/master/packages/react-native/docs/run-android-examples.md Configuration for the 'run-android' target in project.json. ```json { "name": "mobile", //... "targets": { //... "run-android": { "executor": "@nx/react-native:run-android", "options": {} } } } ``` -------------------------------- ### Simple Library Source: https://github.com/nrwl/nx/blob/master/packages/angular/docs/library-examples.md Creates the `my-ui-lib` library with an `ui` tag. ```bash nx g @nx/angular:library libs/my-ui-lib --tags=ui ``` -------------------------------- ### Install Community Formatter Package Source: https://github.com/nrwl/nx/blob/master/packages/eslint/src/migrations/update-23-1-0/convert-to-flat-config.md When a built-in ESLint formatter is removed, install the corresponding community package to maintain the same output format. This example shows how to install `eslint-formatter-junit`. ```bash # Example: keep junit output by installing the community formatter package. npm install --save-dev eslint-formatter-junit ``` -------------------------------- ### Specify style extension Source: https://github.com/nrwl/nx/blob/master/packages/react/docs/application-examples.md Create a React application named 'my-app' in the 'my-dir' directory and specify 'scss' for styles. ```bash nx g @nx/react:app apps/my-dir/my-app --style=scss ``` -------------------------------- ### Install NPM Packages and CocoaPods Source: https://github.com/nrwl/nx/blob/master/packages/expo/docs/prebuild-examples.md Example of configuring the prebuild target to install NPM packages and CocoaPods. ```json "prebuild": { "executor": "@nx/expo:prebuild", "options": { "install": true } } ``` -------------------------------- ### In a nested directory Source: https://github.com/nrwl/nx/blob/master/packages/web/docs/application-examples.md Create an application named `my-app` within a nested directory structure. ```bash nx g @nx/web:app apps/my-dir/my-app ``` -------------------------------- ### Get Status Interactively Source: https://github.com/nrwl/nx/blob/master/packages/expo/docs/build-list-examples.md Example of configuring the 'interactive' option to use interactive mode. ```json "build-list": { "executor": "@nx/expo:build-list", "options": { "interactive": true } } ``` -------------------------------- ### Get Status in JSON Format Source: https://github.com/nrwl/nx/blob/master/packages/expo/docs/build-list-examples.md Example of configuring the 'json' option to output results in JSON format. ```json "build-list": { "executor": "@nx/expo:build-list", "options": { "interactive": false, "json": true } } ``` -------------------------------- ### Get Status of Different Platforms Source: https://github.com/nrwl/nx/blob/master/packages/expo/docs/build-list-examples.md Example of configuring the 'platform' option to check build status for a specific platform. ```json "build-list": { "executor": "@nx/expo:build-list", "options": { "platform": "ios" } } ``` -------------------------------- ### Application using Vite as bundler Source: https://github.com/nrwl/nx/blob/master/packages/react/docs/application-examples.md Create a React application named 'my-app' using Vite as the bundler. Unit tests will be set up with Vitest by default. ```bash nx g @nx/react:app apps/my-app --bundler=vite ``` -------------------------------- ### Quick Start Commands Source: https://github.com/nrwl/nx/blob/master/benchmarks/README.md Commands to run all benchmarks, or a single benchmark, using the Nx CLI. ```bash # Run all benchmarks and compare against goals + baseline pnpm nx run benchmarks # Run a single benchmark pnpm nx bench:version benchmarks pnpm nx bench:show-projects benchmarks pnpm nx bench:cat-warm benchmarks pnpm nx bench:copy-warm benchmarks ``` -------------------------------- ### Serve command Source: https://github.com/nrwl/nx/blob/master/packages/vite/docs/build-examples.md Command to serve the my-app application. ```bash nx serve my-app ``` -------------------------------- ### package.json Source: https://github.com/nrwl/nx/blob/master/packages/rollup/docs/rollup-examples.md To include dependencies in the output package.json, they must be installed as dependencies in the root package.json. ```json { "dependencies": { "some-dependency": "^1.0.0" } } ``` -------------------------------- ### Create a new lib Source: https://github.com/nrwl/nx/blob/master/packages/next/docs/library-examples.md Creates a new library with the specified name. ```shell nx g lib libs/my-lib ``` -------------------------------- ### Adding a New Redirect Example Source: https://github.com/nrwl/nx/blob/master/nx-dev/nx-dev/DEPLOYMENT.md An example demonstrating how to add new redirect rules to the _redirects file, including section and wildcard rules. ```text # --- myNewSection --- /old-feature /docs/new-feature 301 /old-feature/* /docs/new-feature/:splat 301 ``` -------------------------------- ### Specify host for the server Source: https://github.com/nrwl/nx/blob/master/packages/expo/docs/start-examples.md Configuration to specify the host type for the Expo development server. ```json "start": { "executor": "@nx/expo:start", "options": { "port": 8081, "host": "localhost" } } ``` -------------------------------- ### Detect Karma usage in project.json Source: https://github.com/nrwl/nx/blob/master/packages/angular/src/migrations/update-23-1-0/add-istanbul-instrumenter.md This example demonstrates a `project.json` configuration where Karma is used as the runner for the `test` target, triggering the `istanbul-lib-instrument` installation. ```json // project.json { "targets": { "test": { "executor": "@nx/angular:unit-test", "options": { "runner": "karma" } } } } ``` -------------------------------- ### Create a Dynamic Page Source: https://github.com/nrwl/nx/blob/master/packages/next/docs/page-examples.md Generates a dynamic page at apps/my-app/pages/products/[id]/page.tsx. ```shell nx g page "apps/my-app/pages/products/[id]" ``` -------------------------------- ### Install Cypress Component Configuration Source: https://github.com/nrwl/nx/blob/master/packages/angular/docs/cypress-component-configuration-examples.md Command to generate Cypress component configuration for an Angular project. ```shell nx g @nx/angular:cypress-component-configuration --project=my-cool-angular-project ``` -------------------------------- ### Run the preview server Source: https://github.com/nrwl/nx/blob/master/packages/vite/docs/preview-server-examples.md Command to run the preview server for a specific application. ```bash nx preview my-app ``` -------------------------------- ### Project configuration with build target Source: https://github.com/nrwl/nx/blob/master/packages/next/docs/build-next-executor-examples.md This is a sample project.json configuration showing the @nx/next:build executor setup. ```json //... { "name": "acme", "$schema": "node_modules/nx/schemas/project-schema.json", "sourceRoot": ".", "projectType": "application", "targets": { //... "build": { "executor": "@nx/next:build", "outputs": ["{options.outputPath}"], "defaultConfiguration": "production", "options": { "outputPath": "dist/acme" } } //... } } ``` -------------------------------- ### Buildable Library Source: https://github.com/nrwl/nx/blob/master/packages/angular/docs/library-examples.md Creates the `my-lib` library with support for incremental builds. ```bash nx g @nx/angular:library libs/my-lib --buildable ```