Home > Web Front-end > Front-end Q&A > The nodejs project only uploads dist

The nodejs project only uploads dist

王林
Release: 2023-05-13 22:29:38
Original
682 people have browsed it

During the development process, we usually use many tools and frameworks to assist development. These tools and frameworks will generate some products after development, such as packaged code, compiled files, compressed resources, etc. When deploying these products to the production environment, we usually only need to upload these products, without uploading the code and configuration files of the entire development process. Doing so can reduce the size of uploaded and downloaded files, reduce network transmission time, and improve the speed and efficiency of deployment.

For Node.js projects, we can only upload products in the dist directory. The dist directory is usually the packaged output directory, containing compiled JavaScript code, executable files, static resources, etc. Before uploading these products, you need to confirm whether the packaged output directory is correct, whether it contains the files required by the project, and whether it can run correctly. At the same time, you need to add packaging commands to the build script to ensure that new products are generated every time you build and previous products are cleaned up.

In actual deployment, you can use tools such as ftp to upload the product to the server, and use remote command line tools for deployment and startup. For example, use pm2 to start the executable file, use nginx to configure the reverse proxy, etc.

Using only the dist method for deployment can reduce the size of uploaded and downloaded files and improve the speed and efficiency of deployment. At the same time, it can also better protect the security of the code and avoid uploading sensitive files during the development process to the server.

Finally, it should be noted that only uploading dist is not suitable for all projects. For some projects that require dynamic code execution, such as some dynamically compiled language development projects or some projects that require dynamic page generation, the entire code and configuration files need to be uploaded. Therefore, the specific application needs to be selected according to the characteristics of the project.

The above is the detailed content of The nodejs project only uploads dist. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template