Build the seajs project1: preparation
来源:互联网 发布:淘宝店规划书 编辑:程序博客网 时间:2024/05/07 02:30
this article introduces how to concatenate, compress your seajs projects in product environment.
Install the nodejs/npm
see ref:
https://github.com/joyent/node/wiki/Installation
http://joyeur.com/2010/12/10/installing-node-and-npm/
https://gist.github.com/579814
Installing the spm
npm install spm -gnpm install spm-build -gafter install spm, exporting the variable NODE_PATH on the demand of spm, note it's the path that contain spm rather than nodejs on your platform. after installing spm, you can type spm and just follow the tip.
upload your project
upload your project to the server by whatever means.
setup your environment for grunt
a. install grunt CLI
#uninstall globally installed grunt before manipluate your project, we do our stuff under our project folder we upload;#npm uninstall -g gruntnpm install -g grunt-cli
the functionality of grunt-cli is to search which version of grunt should run, it allow multiple version of grunt be installed on system; when node's require() get called, grunt-cli make user able to run grunt from any subfolder of ur project. the specific imple for grunt-cli is https://github.com/gruntjs/grunt-cli/blob/master/bin/grunt.
b. installing grunt
installing the grunt under your project folder:# or u can do this step in d step with --save-dev option after building the package.json and Gruntfile.jsnpm install grunt
c. setup the package.json and Gruntfile.js
package.js is the file needed by npm. you have to list the grunt plugins installed in 'devDependencies' in the file.
Gruntfile.js is used to define and configure tasks.
grunt-init create a project specific package.json. npm init will create a basic package.json;
d. installing the grunt plugin that spm build need.
according to the sample provied by seajs.org, hello sample:https://github.com/seajs/examples/blob/master/static/hello/Gruntfile.js
so install these 4 plugins under project root folder, it's where your uploaded project root folder is.
npm install grunt --save-devnpm install grunt-cmd-transport --save-devnpm install grunt-cmd-concat --save-devnpm install grunt-contrib-uglify --save-devnpm install grunt-contrib-clean --save-dev
note, using --save-dev option will writing the plugin info into your package.json's devDependencies section. you don't need edit it manually.
Setting up your Gruntfile.js
ref:Getting started: http://gruntjs.com/getting-started
Sample Gruntfile: http://gruntjs.com/sample-gruntfile
Configuring tasks: http://gruntjs.com/configuring-tasks
I think these 3 articles is a must to read before your tackling the project.
it's the grunt-cmd-transport plugin that actually extract the id from each module file your have written in your seajs projects, converting the module's define function into the 3-param form of it. see why there is need to extract id here: https://github.com/seajs/seajs/issues/426;
concat : combine all js file, producing one source file and one debug-src file;
uglify: compress js.
I made some small fix to the hello sample Gruntfile.js and grunt-cmd-transport plugin proviede by seajs.org, otherwise the build will not success.
- Build the seajs project1: preparation
- Build the seajs project 2: editing the Gruntfile
- 读书札记:The build process failed during preparation of the resulting assembly
- Preparation
- Do the preparation work when you are idle
- The preparation for installing Oracle after installing OS
- SQL Interview Preparation (in the context of MS SQL Server)
- SeaJS
- seajs
- seajs
- SeaJS
- SeaJs
- SeaJs
- seaJS
- seajs
- SeaJS
- seajs
- seajs
- poj 1222 EXTENDED LIGHTS OUT 高斯消元
- STM32F4 MDK新建使用库的工程
- 带链的栈的实现和操作
- 《算法导论》读书笔记之第13章 红黑树 (转自博客园)
- svm_light使用介绍
- Build the seajs project1: preparation
- 设计模式基本原则
- vsftpd配置文件详解
- 【Android 开发】:UI控件之 ProgressBar 进度条的使用
- 谭浩强第六章习题答案
- STM32F4 GPIO 呼吸灯【库函数操作】
- 循环引用问题,
- 【字符串替换 113】
- 《算法导论》读书笔记之第12章 二叉查找树