frontend-tool - 前端構建、打包工具
一個方便增量打包的前端工具
特性
- 可選擇項目進行構建,build目錄:未壓縮的合并文件,方便調試和比對文件;dist目錄:待打包的壓縮文件
- 可選擇項目進行打包,包中的css、js、img均為增量文件,css、js頭部帶git版本號和最新修改的作者
- 打包完成的css、js可通過build目錄下對應的文件與線上文件進行比對
- css中的靜態文件均帶有版本號 </ol>
- git、node、grunt環境
- 安裝node webkit,http://nwjs.io/
- 配置全局變量,添加git、beyondcompare到path
- git配置,本工具使用git https(ssh您可以自行嘗試)的方式
- git config --global diff.tool bc3
- git config --global difftool.bc3.cmd 'BCompare "$LOCAL" "$REMOTE"'
- git config --global difftool.prompt false
- git config --global credential.helper store
- git config user.name yourname
- git config user.email yourname@test.com </ul> </li>
- 目錄結構:node-webkit下的文件直接復制到安裝完的nodewebkit目錄下;grunt目錄為測試grunt配置;example為測試項目
- 配置文件:
- node-webkit下的config.json
- git 遠程git地址(https)
- grunt 本地grunt目錄
- hasHtml 是否需要自動編譯和打包html文件
- environment 可添加測試環境、生產環境等,url-該環境下靜態文件的根目錄,name-環境名稱 </ul> </li>
- grunt目錄下的package.json
- root 您的本地項目路徑 </ul> </li>
- grunt目錄下的project目錄
- project-list.json 增加刪除項目
- 其余文件:project-list.json中項目對應的grunt配置文件 </ul> </li> </ul> </li> </ul>
注意事項
- 使用jwt等純web service方式加載數據的項目建議使用example/html下的例子,頁面使用.html文件,配置hasHtml為true即可以使用html的自動編譯和打包功能
- 使用.jsp,.php等服務端語言的頁面,您需要在gruntfile中自行生成帶版本號的文件(需要和構建生成的config.json中的文件的md5值保持一致)。頁面中需要加上諸如$getVersion('projecta/css/main.css')這樣的方法生成文件的版本號</pre>
- node-webkit下的config.json
使用步驟
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!