Getting started with yoeman


The Yeoman workflow is comprised of three core tools for improving your productivity and satisfaction when building a web app. These tools are:

  • yo - the scaffolding tool from Yeoman

  • bower - the package management tool

  • grunt - the build tool

我的系统:linux deepin 2014.1 桌面版 64位


Installing yo and some generators

First, you'll need to install yo and other required tools:

sudo npm install -g yo bower


Basic scaffolding


sudo npm install -g generator-webapp

This is the default web application generator that will scaffold out a project containing HTML5 Boilerplate, jQuery, Modernizr, and Bootstrap. You'll have a choice during the interactive prompts to not include many of these.

Now that the generator is installed, create a directory for your new project

mkdir my-yo-project
cd my-yo-project

and then run:

yo webapp

然后就生成一个最简单的web app了。


Bower is a package manager for the web which allows you to easily manage dependencies for your projects. This includes assets such as JavaScript, images and CSS. It is maintained by Twitter and the open-source community.

Managing packages using Bower can be done using the following commands:

# Search for a dependency in the Bower registry.
$ bower search <dep>

# Install one or more dependencies.
$ bower install <dep>..<depN>

# List out the dependencies you have installed for a project.
$ bower list

# Update a dependency to the latest version available.
$ bower update <dep>

Using Bower with a project scaffolded using yo

To create a basic web app with a dependency on a jQuery plug-in:

# Scaffold a new application.
$ yo webapp

# Search Bower's registry for the plug-in we want.
$ bower search jquery-pjax

# Install it and save it to bower.json
$ bower install jquery-pjax --save

# If you're using RequireJS...
# (be aware that currently the webapp generator does not include RequireJS and the following command only applies to generators that do)
$ grunt bower
# Injects your Bower dependencies into your RequireJS configuration.

# If you're not using RequireJS...
$ grunt wiredep
# Injects your dependencies into your index.html file.

Your chosen generator may not include the grunt tasks "bower" and "wiredep". You can read more about how to install and use these at grunt-bower-requirejs and grunt-wiredep.


Grunt is a task-based command-line tool for JavaScript projects. It can be used to build projects, but also exposes several commands which you will want to use in your workflow. Many of these commands utilize Grunt tasks under the hood which are maintained by the Yeoman team.

Grunt commands

# Preview an app you have generated (with Livereload).
$ grunt serve

# Run the unit tests for an app.
$ grunt test

# Build an optimized, production-ready version of your app.
$ grunt

These commands can be used together with the yo binary for a seamless development workflow:

$ yo webapp
$ grunt serve
$ grunt test
$ grunt
阅读 2k

linuxer vimer

前端, angular, vue

841 声望
16 粉丝
0 条评论

前端, angular, vue

841 声望
16 粉丝