基於Grunt的版本構建系統入門教程,grunt構建入門教程

來源:互聯網
上載者:User

基於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更詳細的教程。

參考文檔

  1. Getting started
  2. 使用GruntJS構建Web程式 (2)

附錄

推薦使用grunt-init工具來自動建立項目,目前官方維護以下列表的模板:

  1. grunt-init-commonjs - Create a commonjs module, including Nodeunit unit tests.
  2. grunt-init-gruntfile - Create a basic Gruntfile.
  3. grunt-init-gruntplugin - Create a Grunt plugin, including Nodeunit unit tests.
  4. grunt-init-jquery - Create a jQuery plugin, including QUnit unit tests.
  5. grunt-init-node - Create a Node.js module, including Nodeunit unit tests.

系統的ps教程視頻,新手 詳細的入門教程

直接發太大了,給你個(見附件↓↓↓↓↓ ),各版本PS教程都有,希望有所協助!

 
protege41的新手入門教程,最好是中文版本的protege4版本跟protege3版本差的也太多了吧

我只有英文版的,1.1和1.2的,主要以構建一個Piza本體為主線介紹的,需要的話打聲招呼
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.