基於Grunt的版本構建系統入門教程,grunt構建入門教程
作者:zhanhailiang 日期:2014-10-12
1. 安裝nodejs,npm,grunt-cli,參見《Windows環境下安裝nodejs+npm+grunt-cli工具》。
2. 建立測試專案目錄如下:
其中各檔案模板如下:
src/index.js
var a = 1;var b = 2; function test() { alert(1);} var test2 = function() { return 3;}; test();test2();
package.json(入門學習可先使用該模板)
{ "name": "test", "version": "1.0.0", "description": "test", "author": "", "dependencies": {}, "devDependencies": { }}
Gruntfile.js(實現js壓縮構建任務)
module.exports = function(grunt) { // 配置 grunt.initConfig({ pkg : grunt.file.readJSON('package.json'), uglify : { build : { src : 'src/index.js', dest : 'dest/index.min.js' } } }); grunt.loadNpmTasks('grunt-contrib-uglify'); // 註冊預設任務 grunt.registerTask('default', ['uglify']);};
3. 在當前測試專案根目錄下執行npm install grunt-contrib-uglify –save-dev安裝相應相依模組(註: –save-dev將相依模組自動更新到package.json檔案中):
4. 在當前測試目錄下執行grunt構建任務實現版本構建任務:
5. 至此版本任務構建就算完成了,可以注意到在dest目錄下產生相應的壓縮檔:
由此簡單教程可相應實現CSS壓縮,html壓縮,圖片壓縮等相關版本構建任務。
總之,grunt的功能相當強大,後續筆者將會陸續分享關於grunt更詳細的教程。
參考文檔
- Getting started
- 使用GruntJS構建Web程式 (2)
附錄
推薦使用grunt-init工具來自動建立項目,目前官方維護以下列表的模板:
- grunt-init-commonjs - Create a commonjs module, including Nodeunit unit tests.
- grunt-init-gruntfile - Create a basic Gruntfile.
- grunt-init-gruntplugin - Create a Grunt plugin, including Nodeunit unit tests.
- grunt-init-jquery - Create a jQuery plugin, including QUnit unit tests.
- grunt-init-node - Create a Node.js module, including Nodeunit unit tests.
系統的ps教程視頻,新手 詳細的入門教程
直接發太大了,給你個(見附件↓↓↓↓↓ ),各版本PS教程都有,希望有所協助!
protege41的新手入門教程,最好是中文版本的protege4版本跟protege3版本差的也太多了吧
我只有英文版的,1.1和1.2的,主要以構建一個Piza本體為主線介紹的,需要的話打聲招呼