ã¡ããã¢ããã¹ã«é¨ã®ããã³ãã¨ã³ãã¨ã³ã¸ãã¢æä¸(@pipopotamasu)ã§ãã
æè¿çãã¬ã«æéãå²ããã家ã§ã³ã¼ããæ¸ãæéãæ¸ã£ã¦ãã¾ã£ãã®ãæ©ã¿ã®ç¨®ã§ãã
ä»æ¥ã¯æè¿ä½ã£ãã¡ããã¢ç¨Railsããã³ãã¨ã³ãã®ãã¤ã©ã¼ãã¬ã¼ãããmedpackerããç´¹ä»ãããã¨æãã¾ãã
medpackerä½æã®èæ¯
Railsã«ã¯å ¬å¼ã§å¤§ããåãã¦2ã¤ã®ããã³ãã¨ã³ãã®ç°å¢ãããã¾ããã¢ã»ãããã¤ãã©ã¤ã³ã¨webpackerã§ãã ãããã¯ã¡ããã¢ã®æ¢åãããã¯ãã§ã使ã£ã¦ããã®ã§ããããããã¯ãã®è¦æ¨¡ã大ãããªã£ãããæéãçµã¤ã«ã¤ãã¦è²ã ãªè¾ã¿ãè¦ããããã«ãªã£ã¦ãã¾ããã
ã¢ã»ãããã¤ãã©ã¤ã³
- æçµçã«JSãCSSã®ãã¡ã¤ã«ã1ã¤ã®ãã¡ã¤ã«ã«åºåãããããããã¸ã§ã¯ãã大ãããªã£ã¦ããã¨ãã¡ã¤ã«ãµã¤ãºã大ãããªã£ã¦ãã¾ã(ãã£ãã·ã¥ãå¹ãã¦ãªãã¨èªã¿è¾¼ã¿ãé ããããéçºæã®ãã«ãã«æéãããã)
- ES6+ã使ãããå ´åã¯webpackçã®Bundlerãèªåã§è¨å®ããå¿ è¦ããã(ã¾ãã¯bundlerãwrapãã¦ããgemã使ãå¿ è¦ããã)
webpacker
- ã¢ã»ãããã¤ãã©ã¤ã³ã®æ¬ ç¹ã解æ¶(è¤æ°ãã¡ã¤ã«åºåãwebpackãè¨å®æ¸ã¿)ããã®ã¯ããããwebpackã®è¨å®ãrailsã«ã©ããããããã¦ãã¦ãããã¥ãã
- åæè¨å®ã ã¨ãããã¯ã·ã§ã³ãã«ãã«source mapãã¤ãã¦ããããªã©ï¼ãªè¨å®ããã
- webpackæ¬ä½ã®ãã¼ã¸ã§ã³ã¢ããã«ã¤ãã¦ããã¦ãªã(webpackãv4ãªã®ã«å¯¾ãã¦ãwebpackerã¯webpack v3ä¾å)
ãããã®è¾ã¿ã®ããæ°è¦ã§Railsããã¸ã§ã¯ããä½æããæãä»ã¾ã§éãã¢ã»ãããã¤ãã©ã¤ã³ãwebpackerã§æ§ç¯ãã¦ãã¾ã£ã¦ããã®ãã¨ããçåãçãã¦ãã¾ããã ã¾ãããã³ãã¨ã³ãéçºãã¡ã¤ã³ã§è¡ãã®ããµã¼ãã¼ãµã¤ãã¨ã³ã¸ãã¢ãå¤é¨ã®ããã³ãã¨ã³ãã¨ã³ã¸ãã¢ããã¨ãããã¨ããããããã¸ã§ã¯ãéã§æ¡ç¨æè¡ã質ãæ¨æºåããããã«ãã¾ãããã³ãã¨ã³ãã®ç°å¢æ§ç¯ã®æéç縮ã®ããRailsããã³ãã¨ã³ãç¨ã®ãã¤ã©ã¼ãã¬ã¼ããç¨æãããã横å±éããã®ãããã®ã§ã¯ãªããï¼
ã¨ãããã¨ã§ããããã®è¾ã¿ãå æããããã«ã¡ããã¢ç¨Railsããã³ãã¨ã³ãç¨ã®ãã¤ã©ã¼ãã¬ã¼ããmedpackerããä½æãã¾ããã
medpackerã®ã³ã³ã»ãã
medpackerã®ã³ã³ã»ããã¯å¤§ãã2ã¤ã§ãã
ç´ æ©ããç°¡åã«å°å ¥ã§ãã
webpackerã®ãããªå°å ¥ã®ç°¡åããç®æããRailsã®ã¢ããªã±ã¼ã·ã§ã³ãã³ãã¬ã¼ãã使ç¨ãã¦è¨å®ã§ããããã«ãã¦ãã¾ããããã«ããrails newããã¦ãã2~3åã§ããã³ãã¨ã³ãç°å¢ãæ§ç¯ãããã¨ãã§ãã¾ãã
ã ãããéçºãæ¬çªç°å¢ã§å¿ è¦ãªãã®ãåæããè¨å®ããã¦ãã
ã¢ããªã±ã¼ã·ã§ã³ãã³ãã¬ã¼ãã§å°å ¥ããç´å¾ãããwebpackã»babelã»lintã»postcssã»minifyçããã§ã«ã»ããã¢ããããã¦ãããããããã«éçºã«çæã§ããããã«ãªã£ã¦ãã¾ãã
Get started! å®éã«medpackerãå°å ¥ãã¦ã¿ã
ããã§ã¯å®éã«medpackerãå°å ¥ãã¦ã¿ã¾ãããã
STEP1: medpackerããã¼ã«ã«ã«cloneãã
$ git clone https://github.com/medpeer-inc/medpacker.git
STEP2: rails newããç´å¾ã®railsããã¸ã§ã¯ããç¨æãã
$ rails new test-project
STEP3: ã¢ããªã±ã¼ã·ã§ã³ãã³ãã¬ã¼ããç¨ãã¦ãå ã»ã©ä½æããããã¸ã§ã¯ãã«medpackerãé©ç¨ãã
$ cd test-project $ bin/rails app:template LOCATION=path/to/medpacker/template.rb
ãã®éããã¤ãCLIã«è³ªåãããã®ã§ãç¨éã«å¿ãã¦çãã¦ãã ããã
remove 'app/assets'? y remove 'test/'? y need example page? y Overwrite /Users/yamatomurakami/work/test-project/config/routes.rb? (enter "h" for help) [Ynaqdhm] a
STEP:4 railsãèµ·åãã
$ bin/rails s
ãµã¼ãã¼ãèµ·åãã以ä¸ã®ç»é¢ãåºããå°å ¥å®äºã§ã
( â»need example page?
ã«yesã§çããªãã¨ãã®ãã¼ã¸ã¯è¡¨ç¤ºããã¾ãã)ã
medpackerã®ä¸èº«ã«ã¤ãã¦
ä½æã«è³ã£ãèæ¯ãã³ã³ã»ãããªã©ã¯ãã§ã«èª¬æããéãã§ããããã§ã¯medpackerã®ä¸èº«ã«ã¤ãã¦ã¿ã¦ããã¾ãã
webpack
medpackerã®æ ¸ã¨ãããã¹ãbundlerã§ãã ãã¡ããããã³ãã¨ã³ãã®ã¢ã»ããããã«ãããããã«å ¥ãã¦ã¾ãã Railså´ã§ãã«ãããã¢ã»ãããHTMLã«èªã¿è¾¼ãããã®ãã«ãã¼ãç¨æãã¦ãããããã使ããã¨ã§èªã¿è¾¼ããã¨ãã§ãã¾ãã productionã¢ã¼ãã§ãã«ãããã¨CSS, JSãminifyãããããã«ãªã£ã¦ãã¾ãã
webpack-dev-server
webpackã§ã®éçºããµãã¼ããããã¼ã«ã§ãããã£ãã以ä¸ã®ãããªæ©è½ãããã¾ãã
JSãå¤æ´ããæå·®åã®ãã«ãããã¦ããã(webpackã®watchã¨åã)
ãªãã¼ãããã«æ´æ°ãããã¡ã¤ã«ããã©ã¦ã¶ã«é©ç¨ããã(Hot module replacement, HMR)
ä¸è¨ã®HMRãã§ããªãå ´åã¯èªåçã«ãã©ã¦ã¶ããªãã¼ãããæ´æ°åã®ã¢ã»ãããåå¾ãã
CSS(SCSS), PostCSS
å°å ¥æç¹ã§ãSCSSã¨PostCSSã®è¨å®ãããã¦ãã¾ãã
(â»ã¡ããã¢ã§ã¯å ¨ã¦ã®Railsããã¸ã§ã¯ãã§SCSSã使ç¨ãã¦ããã®ã§ã決ãæã¡ã§å ¥ãã¦ããã¾ã)
ã¾ãPostCSSã§åæå°å ¥ããã¦ãããã©ã°ã¤ã³ã¯ä»¥ä¸2ã¤ã§ãã
- autoprefixerã»ã»ã»èªåçã«ãã³ãã¼ãã¬ãã£ãã¯ã¹ãã¤ãã¦ãããã©ã¤ãã©ãª
- postcss-flexbugs-fixesã»ã»ã»ãã©ã¦ã¶ãæ½å¨çã«æã£ã¦ããflexboxã®ãã°ãè¸ã¾ãªãããã«ãèªåæ´å½¢ãã¦ãããã©ã¤ãã©ãª
babel
JSãè²ã ãªãã©ã¦ã¶ã§èªã¿è¾¼ããããã«(ä¾ãã°ææ°ã®è¨æ³ãå¤ããã©ã¦ã¶ã§ãèªã¿è¾¼ããããã«)å¤å½¢/代æ¿ãã¦ãããã©ã¤ãã©ãªã«ãªãã¾ãã å°å ¥æç¹ã§è¨å®æ¸ã¿ãªã®ã§ãIE11ã¨ãæ°ã«ããã«JSãæ¸ãã¦ãåé¡ããã¾ããã
åºæ¬çã«ã¡ããã¢ã®æ¨å¥¨ç°å¢ã«åããã¦ããã¾ããããã®è¾ºããããã°å¯¾å¿ãã©ã¦ã¶ãå¤ãããã¨ãã§ãã¾ãã
lintç³»
SCSSã®lint(stylelint)ã¨JSã®lint(eslint)ã®2ã¤ãè¨å®æ¸ã¿ã§ããå°å ¥å´ã®ããã¸ã§ã¯ãã®CIã«çµã¿è¾¼ãã§ããã¦ãã ããã
Vue.js
medpackerã«å ¥ãããè¿·ã£ãã®ã§ãããå°å ¥æã«Vue.jsãåæè¨å®ãã¦ããã¾ãã å人çã«JSã©ã¤ãã©ãªãå ¥ããã®ã¯æ¬å½ã«å¿ è¦ã«ãªã£ãæã«åãã¦å ¥ããã°ããã¨æã£ã¦ããã®ã§ãããããã¸ã§ã¯ãéã§ã®æ¡ç¨æè¡ãçµ±ä¸ããããã«å ¥ãã¦ããã¾ã(以åã¨ãããããã¯ãã§å¤é¨ã®ã¨ã³ã¸ãã¢ããã«ãæä¼ããã¦ããã ãã¦ãæã社å ã®ã»ã¨ãã©ã®ããã¸ã§ã¯ãã§Vue.jsã使ã£ã¦ããã«ãé¢ããããããã£ã¨Reactãå ¥ã£ã¦ãããã¨ããã£ãã®ã§...)ã
工夫ããã¨ãã
ã©ã¤ãã©ãªã¢ãããã¼ã
æ1åã®ãã¼ã¹ã§ãèªåçã«gemã¨npmã®ã¢ãããã¼ãPRãCIã§ä½ãããããã«ãªã£ã¦ãã¾ãã ä½æå¾ã¯ç§ãPRå 容ã®ç¢ºèªã»ãã¼ã¸ããã¦ãã¾ã(ãã®è¾ºã¯æåã§ã)ã ãmedpackerãé©ç¨ãããã¨ããããã¼ã¸ã§ã³ãå¤ã...ãã¨ããã¡ã³ããããã«æ¾ç½®ãããã¨ããäºæ ã¯é¿ããããã«ãã¦ãã¾ãã
ã¢ããªã±ã¼ã·ã§ã³ãã³ãã¬ã¼ãã®ä½¿ç¨
ãã楽ã«ããã¸ã§ã¯ãã«medpackerãé©ç¨ããããã«Railsã®ã¢ããªã±ã¼ã·ã§ã³ãã³ãã¬ã¼ãã使ç¨ãã¾ããã æåã¯ãã®ä¾¿å©æ©è½ã®åå¨ãç¥ããã«ããã¡ãã®æ¹æ³ãã¡ã¤ã³ã®é©ç¨æ¹æ³ã«ã¨èãã¦ãã¾ãããä»èããã¨ã¨ã¦ã¤ããªã使ãã¥ããã§ããããã
çµããã«
ç¾å¨ã¡ããã¢ã§ã¯3ã¤ã®ãããã¯ãã§medpackerã使ç¨ãã¦ãã¾ãã 使ã£ã¦ãããã¡ã«åºã¦ããæ¹åç¹ã追å æ©è½ãªã©ã¯æ¥ã æ´æ°ãã¦ããäºå®ã§ãã
ãããã®ããã°ãè¦ã人ã§ããã¡ã§ã¯ãããªã®ä½¿ã£ã¦ããã¼ãã¨ãç¥è¦ããã人ã¯ãã£ããæãã¦ããã ããããããããã§ããmedpackerã«åãå ¥ããããããã¾ããã
ã¾ããã®medpackerãä½ãä¸ã§pixivãããã¹ã¿ãã£ã¹ãããã®ããã°ãåèã«ããã¦ããã ãã¾ãããæ¬å½ã«ãããã¨ããããã¾ããã
今日から簡単!Webpacker 完全脱出ガイド - pixiv inside
フロントエンド原理主義者が目論んだ脱webpacker – スタディスト開発ブログ – Medium
(âï¸ ÕਠÕ)âï¸æ¯éèªè ã«ãªã£ã¦ãã ãã
ã¡ããã¢ã§ã¯ä¸ç·ã«åã仲éãåéãã¦ãã¾ãã ãå¿åããå¾ ã¡ãã¦ããã¾ãï¼
â åéãã¸ã·ã§ã³ã¯ãã¡ã
https://medpeer.co.jp/recruit/entry/
â éçºç°å¢ã¯ãã¡ã