問題描述
我正在嘗試一些現代 Javascript 框架,例如 Angular、React、Vue 和 Ember,它們都希望我使用構建工具,例如 npm
、grunt
、gulp
、maven
等
I'm trying out some modern Javascript frameworks like Angular, React, Vue and Ember, and they all want me to use build tools like npm
, grunt
, gulp
, maven
, etc.
Web 編程曾經很有趣.只需更改一些文件,刷新瀏覽器,看看它是否有效.現在每次我改變一些東西,我都必須重新構建它,這需要相當長的時間.我真的很討厭看到網絡編程變成了這樣.我知道構建甚至可以使用這些工具自動完成,監視文件更改等,但仍然很糟糕.
Web-programming used to be fun. Just change some files, refresh the browser and see if it works. Now every time I change something, I have to build it again, which takes quite some time. I really hate to see that web-programming has become like this. I know the building can even be done automatically with these tools watching for file-changes, etc., but still, it just sucks.
我的問題是,當我想使用上述框架之一時,我應該在每次運行時都使用構建工具,還是只需要這些用于部署和測試目的(或者根本不需要) ?
My question is, when I want to use one of the mentioned frameworks, am I supposed to use the build-tools every time I want to run, or do I just need these for deployment and testing purposes (or not at all) ?
推薦答案
有些庫需要構建代碼,有些則不需要.從您擁有的列表中,它們在技術上都不需要它.它們都可以通過簡單地將 js 文件包含在 <script>
標記中來工作.但是,有許多框架/庫(例如 sass 或 coffeescript)確實需要構建工具,因為必須將源代碼編譯為瀏覽器所理解的 html/javascript/css.
Some libraries require building the code, some don't. From the list that you had, none of them require it technically. They can all work by simply including the js file in a <script>
tag. However, there are many frameworks/libraries (such as sass or coffeescript) which do require a build tool, because the source code must be compiled to become html/javascript/css as understood by the browser.
此外,沒有任何理由反對使用構建工具.正如您所說,它們可以在文件更改時自動運行,因此它們實際上只是在后臺.
Also, there's not really any reason to be so against using build tools. As you said, they can run automatically on file change, so they're really just in the background.
這篇關于在沒有構建工具(如 grunt 和 gulp)的情況下使用 Javascript 框架?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!