Getting started with yoeman

发布时间:2019-07-19 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了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

脚本宝典总结

以上是脚本宝典为你收集整理的Getting started with yoeman全部内容,希望文章能够帮你解决Getting started with yoeman所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。