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位

yo

Installing yo and some generators

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

sudo npm install -g yo bower

npmnode.js的包管理器,并和它捆绑在一起。

Basic scaffolding

为了搭建一个web应用,你需要安装一个generator-webapp

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

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

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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值