问题
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-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) ?
回答1:
You don't have to use these tools. They're mostly aimed at people who want to use frameworks in larger projects, and have features that let you compile hundreds of JS components into one file. I personally use them mostly for automating build tests, unit tests, and bundling all the assets together on release days. Let's address the frameworks you mentioned one at a time:
React: React provides an already compiled version of their code on their getting started page
AngularJS: Same as react, there's just a file you can include, just look up "angular cdn"
Vue: They also have a file that you can just include.
Ember: See above
For most frameworks, you can just look up "name of framework CDN" to get an online hosted js file that you can quickly throw in to your projects for web development the old way.
回答2:
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.
来源:https://stackoverflow.com/questions/34503862/use-javascript-frameworks-without-build-tools-like-grunt-and-gulp