karmapa / adarsha2016

adarsha 2016
GNU Affero General Public License v3.0
3 stars 1 forks source link

adarsha.dharma-treasure.org build tool 建置 #28

Open kmsheng opened 8 years ago

kmsheng commented 8 years ago

從 dev server deploy 到 production server 之前要能自動做以下:

  1. image optimization & filename hash ( 可以先測一下線上機器有哪些圖片沒壓 ​https://github.com/addyosmani/tmi )
  2. concat css & uglify & filename hash ( css 內的圖片如果圖片檔案有變也要替換路徑 )
  3. jshint 檢查 js 錯誤
  4. concat js & uglify & filename hash ( 這個要注意 concat 順序, 現在 adarsha.dharma-treasure.org 上有跨檔案共用變數的行為 )
  5. 置換掉 html 上的 image & css link & script links
  6. 把靜態檔案推到 cdn site 上
kmsheng commented 8 years ago

gulp or webpack 有很多 open source plugins 可以做到。 如果技術上有問題也請隨時發問 : )

kmsheng commented 8 years ago
  1. 的話是因為直接用 ec2 那台 web instance serve 靜態檔案有點燒錢 & 吃資源, 所以想說先找個免費 cdn 擋在前面。
yapcheahshen commented 8 years ago

目前adarsha2016 的 bottle neck 在 biographyForWeb.js ,這個js很大,載入和剖析都花時間。 因為 kdb server 不 cache *.js ,cache 的話,上傳 js 客戶端還是舊的。 https://github.com/ksanaforge/ksana-cli/blob/master/lib/server.js#L49

辦法有二: 一)將biographyForWeb.js 改名為 biographyForWeb.txt 這樣 kdb server 就會 加入 ETAG

二)用免費的cdn ,但usb 版的url 要特別注意,否則無法離線使用。

yap

kmsheng notifications@github.com 於 2016年2月24日 上午10:25 寫道:

  1. 的話是因為直接用 ec2 那台 web instance serve 靜態檔案有點燒錢 & 吃資源, 所以想說先找個免費 cdn 擋在前面。

— Reply to this email directly or view it on GitHub https://github.com/karmapa/adarsha2016/issues/28#issuecomment-188016796.

kmsheng commented 8 years ago

biographyForWeb.js 的內容算 data, 不應該以 js 形式載入. 應該改為 json 或用 remote api serve data.

cache 是一定要 cache (Cache Control, Etag), 要 invalidate 可以換掉 html 的 filename suffix.

kmsheng commented 8 years ago

還有, 現在的寫法太隨便就綁東西在 window 上, 感覺很差。

kmsheng commented 8 years ago

補充一下 https://github.com/karmapa/adarsha2016/issues/28#issuecomment-188056334

比較好的做法是以 process.env.NODE_ENV 來區分 development / production development 的話就是為了方便開發, 完全不 cache production 則是可以指定 static folder, 該 folder 完全 cache