# Node.JS Browser This configuration is suitable if the project uses the node.js environment and the npm package manager to build the application for running in the browser. In this case, the project can be written in languages such as JavaScript or TypeScript. This configuration is intended for browser applications. For server applications, see [Node.JS Server](https://docs.amverum.ru/books/amverum/page/nodejs-server). You can write a yaml file yourself, using the instructions below, or use our yaml generator by clicking on [link](https://manifest.amverum.ru/). ## Section meta The `meta` section of the `amverum.yml` file will look like this: ``` yaml meta: environment: node toolchain: name: browser version: 18 ``` The parameter that can be changed here is `meta.toolchain.version`. Logically, this is the version of node.js that should be used for work. Technically, the value of `version` is substituted into the name of the Docker image that will be used. The image `node:${meta.toolchain.version}` is used for the build phase. Since node.js is not used at all for the run phase, `meta.toolchain.version` can be any tag of this image on [docker hub](https://hub.docker.com/_/node/tags). ## Секция build Секция `build` может содержать следующие необязательные параметры: - `additionalCommands` - `artifacts` During the build, the script executes the command `npm install && npm run build`. If the `additionalCommands` parameter is specified, the command `npm install && ${build.additionalCommands}` will be executed. This can be useful if the project's build command is not called `build`. ``` yaml build: additionalCommands: npm run amverum:build ``` The `artifacts` parameter allows you to specify which files should be included in the final application. By default, all files from the `build` folder will be copied to the root of the application folder. Unlike other parameters, the `artifacts` parameter is not a string, but a dictionary. The key in it is the mask of the source files to copy, and the value is the folder to which the files will be copied. So, the default value of `artifacts` is: ``` yaml build: artifacts: "build/*": / ``` We use the following copying rules: - only relative paths are specified as a source (without / at the beginning); - if a file matches the mask, the file will be copied to the destination folder without the source path; - if a folder matches the mask, it will be copied entirely to the destination folder along with all its contents. ## Section run A modified `nginx:1.23.2` image is used for startup to support routing in SPA applications. There are no configurable parameters in the `run` section. ## Recipes ### React ``` yaml meta: environment: node toolchain: name: browser version: 18 ``` ### Vue ``` yaml meta: environment: node toolchain: name: browser version: 18 build: artifacts: "dist/*": / ``` ### Angular ``` yaml meta: environment: node toolchain: name: browser version: 18 build: artifacts: "dist/my-app/*": / ```