且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用离子管理bower依赖关系

更新时间:2023-09-17 23:50:22

拥有 devDependencies 使您有机会简化驱动您从源文件(项目的git克隆)到生产就绪应用程序的步骤

having devDependencies gives you the opportunity to simplify the steps that drive you from the source files (a git clone of the project) to the production ready app

当你不需要进行更改和(开发)应用程序时,你可以运行

when you don't need to make changes and (develop) the application, you could just run

bower install --production

npm install --production

它们的工作方式相同


-F, --force-latest: Force latest version on conflict

-p, --production: Do not install project devDependencies

-S, --save: Save installed packages into the project’s bower.json dependencies

-D, --save-dev: Save installed packages into the project’s bower.json devDependencies

-E, --save-exact: Configure installed packages with an exact version rather than semver


bower文档


默认情况下,npm install将安装列为的所有模块
依赖项。使用--production标志(或当NODE_ENV
环境变量设置为production时),npm将不会安装devDependencies中列出的
模块。
npm文档

这样你就可以减少发布应用程序的时间,也不会浪费带宽下载你不需要的东西。

This way you take less time to ship the app and don't waste bandwidth downloading stuff you won't need.

鉴于此,对我而言,将离子列为devDependecy的选择是一个糟糕的选择:它意味着我可以利用这个选择来准备应用程序以便这样执行:

Given that, to me, the choice of listing ionic as devDependecy is a poor one: it implies that I could take advantage of this choice to get ready the app for execution this way:

git clone my-project
git cd my-project
npm install --production # ionic not installed here
ionic state restore
ionic build ios

现在,如果忽略源中/ lib文件夹的内容,这应该不起作用,如果它有效,因为离子cli做了一些更多的检查来拯救你的屁股,我认为这还不清楚。

Now, if you ignore the content of /lib folder in your sources, this should not work, and if it works because the ionic-cli does some more checks to save your ass, I think this is unclear.