简体   繁体   English

在 web 设计中使用供应商文件夹

[英]Use of vendor folder in web design

I am starting to build a website from scratch using python, django, and bootstrap.我开始使用 python、django 和引导程序从头开始构建网站。 I have noticed that many times js, css, img.我注意到很多时候js,css,img。 and fonts are stored in a folder vendor, such as:和 fonts 存储在文件夹 vendor 中,例如:

/static/js/vendor/bootstrap/bootstrap.min.js
/static/css/vendor/bootstrap/bootstrap.min.css

or something similar.或类似的东西。

What is the benefit of this folder structure over something like:这种文件夹结构相对于以下内容有什么好处:

/static/bootstrap/js/bootstrap.min.js
/static/bootstrap/css/bootstrap.min.css

In the first example, when using the vendor folder as I have often seen, I would have to download bootstrap and unpack the downloaded folder into the js and css vendor sub-directories.在第一个示例中,当使用我经常看到的供应商文件夹时,我必须下载引导程序并将下载的文件夹解压缩到 js 和 css 供应商子目录中。 In the second example, I can download bootstrap and drop the downloaded folder into /static without having to unpack anything.在第二个示例中,我可以下载 bootstrap 并将下载的文件夹放到 /static 中,而无需解压缩任何内容。

它清楚地标记哪些文件是不应直接编辑的第三方库。

The vendor folder is where you usually (I'm using the word 'usually' because it's not exactly a rule but more of a preference in the coding community with the purpose of having a semantic directory structure) keep third-party resources(icons, images, codes, you name it) as opposed to a lib (library) folder where you or the author of the site/application to be specific keep your original codes in. 通常使用vendor文件夹(我通常使用'通常'这个词,因为它不是一个规则,但更多的是编码社区的偏好,目的是拥有语义目录结构)保留第三方资源(图标,图像,代码,您的名字)而不是lib (库)文件夹,您或特定网站/应用程序的作者将保留您的原始代码。

So if I were to download and use the site/application in the hypothetical scenario above, I can then create relevant folders for each data type ( src/images for images, style/css for css, script/js for js, etc ) and move required assets from the lib folder to the new folders without having to edit the third-party codes (or other assets) thus making it easier to rollback on any changes made that causes errors and such. 因此,如果我在上面的假设场景中下载并使用网站/应用程序,我可以为每种数据类型创建相关的文件夹( src/images for images, style/css for css, script/js for js, etc )和将所需资产从lib文件夹移动到新文件夹,而无需编辑第三方代码(或其他资产),从而更容易回滚导致错误等的任何更改。

Well it's all for organizing your data, and it's not necessary means you can don't use it.好吧,这一切都是为了组织您的数据,这并不是说您不能使用它。 But if you organize your files in assets and vendor folders you can easily access them and have a peace of mind.但是,如果您在资产和供应商文件夹中组织文件,则可以轻松访问它们并高枕无忧。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM