前端開發神器WebStorm--Grunt 搭建環境(03)

來源:互聯網
上載者:User

標籤:style   class   blog   code   http   ext   

通過上一篇前端開發神器WebStorm--自動化工作流程(前言),相信大家都Grunt自動化工具有了初步瞭解。接下來我就以WROC3000 web為原型,示範一下如何使用Grunt工具提高工作效率,最大程度壓縮代碼。

 

1.首先安裝node環境進入官網 下載安裝。(記住安裝目錄)檢測安裝成功方法:開啟CMD視窗,輸入
node --version
會列印出安裝的版本號碼,說明已經安裝成功。2.安裝 Grunt 用戶端在CMD 視窗中,切換到node安裝盤符,會自動切換到nodejs安裝目錄。輸入 npm install -g grunt-cli  斷行符號安裝成功後會顯示安裝路徑以及版本號碼。

例如

 

Your environment has been set up for using Node.js 0.10.28 (x64) and npm.C:\Users\佩青>d:D:\Program Files\nodejs>npm install -g grunt-clinpm http GET https://registry.npmjs.org/grunt-clinpm http 200 https://registry.npmjs.org/grunt-clinpm http GET https://registry.npmjs.org/noptnpm http GET https://registry.npmjs.org/findup-syncnpm http GET https://registry.npmjs.org/resolvenpm http 304 https://registry.npmjs.org/noptnpm http 304 https://registry.npmjs.org/findup-syncnpm http 200 https://registry.npmjs.org/resolvenpm http GET https://registry.npmjs.org/abbrevnpm http GET https://registry.npmjs.org/globnpm http GET https://registry.npmjs.org/lodashnpm http 304 https://registry.npmjs.org/abbrevnpm http 200 https://registry.npmjs.org/globnpm http 200 https://registry.npmjs.org/lodashnpm http GET https://registry.npmjs.org/inheritsnpm http GET https://registry.npmjs.org/minimatchnpm http 304 https://registry.npmjs.org/minimatchnpm http 304 https://registry.npmjs.org/inheritsnpm http GET https://registry.npmjs.org/sigmundnpm http GET https://registry.npmjs.org/lru-cachenpm http 304 https://registry.npmjs.org/sigmundnpm http 304 https://registry.npmjs.org/lru-cacheC:\Users\佩青\AppData\Roaming\npm\grunt -> C:\Users\佩青\AppData\Roaming\npm\node_modules\grunt-cli\bin\grunt[email protected] C:\Users\佩青\AppData\Roaming\npm\node_modules\grunt-cli├── [email protected]├── [email protected] ([email protected])└── [email protected] ([email protected], [email protected])D:\Program Files\nodejs>
3.配置WebStorm Grunt環境     建立一個空項目(以ws-Grunt為例),在根目錄建立 GruntFile.js 檔案,選中該檔案右鍵點擊, 選擇,開啟Grunt 控制台。(注意:js檔案的名稱必須是GruntFile,否則按右鍵不會出現)操作過程:

  都看到最後Grunt 控制台有報錯資訊(Error),是因為沒有安裝Grunt服務。下面教大家安裝: 快速按下兩次Shift鍵,就可以看到新彈出來一個視窗(Search EveryWhere),可以搜尋項目中的任何內容。在輸入框中輸入node npm,選擇Actions下的Node.js and NPM, 在新彈出的視窗選擇 ,輸入grunt,點擊 Install Package ,進行安裝。安裝成功後,會有綠色資訊條提示。關閉當前視窗。再點擊OK。此時在根目錄下就會產生node_modules的檔案夾。重新整理Grunt 控制台,錯誤資訊就會消失。

4.配置WebStorm支援Grunt文法提示配置過程如下:

至此,WebStorm 中的配置環境已經搭建完畢。

 

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.