简体   繁体   中英

Use of vendor folder in web design

I am starting to build a website from scratch using python, django, and bootstrap. I have noticed that many times js, css, img. and fonts are stored in a folder vendor, such as:

/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. In the second example, I can download bootstrap and drop the downloaded folder into /static without having to unpack anything.

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

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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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