1、安装基础运行环境
git(bower等要从git上拉依赖)、notejs(grunt本来就基于notejs)、python、ruby(Sass要有ruby开发环境,Sass是一种css的编程语言)
On Windows, we suggest you use an improved command line tool such as cmder or PowerShell to improve the experience.
2、熟悉使用yeoman工具链
2.1 熟悉yo+bower+grunt工具的作用
2.2 了解常用的命令
# Search for a dependency in the Bower registry.
$ bower search <dep>
# Install one or more dependencies. 可以是git地址或一个具体文件或文件路径
$ 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>
# 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
# Preview an app you have generated (with Livereload).
$ grunt server
# Run the unit tests for an app.
$ grunt test
# Build an optimized, production-ready version of your app. 默认运行的是default选项
$ grunt
2.3 了解bower与grunt重要的配置文件
(1)package.json 主要提供给notejs项目npm一些相关的信息
(2)bower.json文件存放在库的根目录下,用于保存项目的库信息,供项目安装时使用,以及Bower的在线索引读取。
(3)Gruntfile.js 模块安装完以后,下一步在项目的根目录下,新建脚本文件Gruntfile.js。
grunt.initConfig:定义各种模块的参数,每一个成员项对应一个同名模块。
grunt.loadNpmTasks:加载完成任务所需的模块。
grunt.registerTask:定义具体的任务。第一个参数为任务名,第二个参数是一个数组,表示该任务需要依次使用的模块。default任务名表示,如果直接输入grunt命令,后面不跟任何参数,这时所调用的模块(该例为jshint,concat和uglify);该例的check任务则表示使用jshint插件对代码进行语法检查。
3、学习requireJS
defind方法:将代码定义为模块
require方法:实现代码的模块加载