[英]NPM production and development on live server
This might be a silly question but I am using npm
first time in my project so I need to know best practice for this.这可能是一个愚蠢的问题,但我第一次在我的项目中使用
npm
所以我需要知道这方面的最佳实践。
How do I manage npm development
and npm production
on local and production server?如何在本地和生产服务器上管理
npm development
和npm production
?
As of now I run npm run development
command when developing and save the compiled files along with other changes on git
.截至目前,我在开发时运行
npm run development
命令并保存编译文件以及git
上的其他更改。
Before I pull all the changes on production server, I run npm run production
command and commit on git
.在我拉出生产服务器上的所有更改之前,我运行
npm run production
命令并在git
上提交。 After that I pull the latest changes on production and then run npm run development
on my local branch.之后,我在生产中提取最新更改,然后在我的本地分支上运行
npm run development
。
What are the best practice to do this?执行此操作的最佳做法是什么?
Thank you谢谢
The 'Best Practice' is that you don't commit any compiled files . “最佳实践”是您不提交任何已编译的文件。
You should use .gitignore
to ignore the folder that your files are compiled into.您应该使用
.gitignore
忽略文件编译到的文件夹。 But before you do that, delete the folder and commit the deletion, so that Git understands those files are gone.但在你这样做之前,删除文件夹并提交删除,以便 Git 了解这些文件已经消失。 Then add the folder to
.gitignore
and you can carry on.然后将文件夹添加到
.gitignore
即可继续。
On your local machine, you can run npm run development
.在您的本地机器上,您可以运行
npm run development
。 Then on your production server, or on a build machine, you can run npm run production
.然后在您的生产服务器或构建机器上,您可以运行
npm run production
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.