ç§ãåãçµãã§ãããããžã§ã¯ãã«ã¯ããŠã£ãžã§ããã®ãããªã¯ã©ã€ã¢ã³ãã¢ãŒããã¯ãã£ããããŸãã ããã«ãã·ã¹ãã ãŠã£ãžã§ããã¯ãReactJSãPolymerJSãVueJSãd3JSãªã©ãå®è£ ã«ä»»æã®ã©ã€ãã©ãªã䜿çšã§ããŸãã PolymerJSã«åºã¥ãWebã³ã³ããŒãã³ãã®ããã«ãããã€ãã®ã·ã¹ãã ãŠã£ãžã§ãããå®è£ ãããŠããŸã ã
ãããã£ãŠãããªããŒãŠã£ãžã§ãããæé©åããæ¹æ³ã®1ã€ã«æ³šç®ããŸãã
å 容ïŒ
1.åé¡ã®èª¬æ
2.ã©ã®ãããªå°é£ãçããŸããïŒ
3.ã©ãããã°è§£æ±ºã§ããŸããïŒ
4. vulcanize-polymer-moduleã©ã€ãã©ãª
4.1ã æ§é
4.2ã bower.jsonã®èª¬æ
4.3ã Package.jsonã®èª¬æ
4.3.1ã ãŠãŒãã£ãªãã£ã®ã€ã³ã¹ããŒã«
4.3.2ã RollupJSãæ§æãã
4.4ã vulcanize-utils.js
5.çµè«
1.åé¡ã®èª¬æ
ããªããŒã¢ããªã±ãŒã·ã§ã³ã®äž»ãªåé¡ã®1ã€ã¯ã䜿çšæžã¿ã³ã³ããŒãã³ããšãã¹ãŠã®äŸåã³ã³ããŒãã³ãã®è€æ°ã®ããŒãã§ãããããã®ã³ã³ããŒãã³ãã¯ãåãæ¹æ³ã§ããŒããããè£å©ã¹ã¿ã€ã«ã§ããbehaviorã§æ§æãããŸãã ãã®çµæããããã¯ãŒã¯ã»ã¯ã·ã§ã³ã®ã³ã³ãœãŒã«ã¯ãããã®ãã¡ã€ã«ã§ãçæããããŸãã ããããã¹ãŠãèæ ®ãããšã䜿çšããè€åWebã³ã³ããŒãã³ãã®æ°ã«ãã£ãŠã¯ããã®ãããªãŠã£ãžã§ããã®æåã®ããŠã³ããŒãã«éåžžã«æéããããå ŽåããããŸãã
ãããã®ç®çã®ããã«ãããªããŒçšéã¯å ç¡«ã䜿çšããŸãã ãã®ã¢ããªã±ãŒã·ã§ã³ã«ã¯ã index.htmlãªã©ã®åœ¢åŒã®ãšã³ããªãã€ã³ããããããã®äžã«<App />ãªã©ã®ã¡ã€ã³ã³ã³ããã³ã³ããŒãã³ãããããã€ãããŠããããšãããããŸãã ãã®ãã¡ã€ã«ã§ã¯ãããªããŒã³ã¢èªäœãšã³ã³ããã³ã³ããŒãã³ããã¡ã€ã«<App />ãæ¥ç¶ããããã®åŸãããèªäœãåå¥ã®htmlãã¡ã€ã«ã§ãã䜿çšæžã¿ã³ã³ããŒãã³ãããã¹ãŠéå±€çã«æ¥ç¶ãããŸãã å ç¡«ããã»ã¹èªäœã¯ããã¹ãŠã®äœ¿çšæžã¿ã³ã³ããŒãã³ããšããªããŒã³ã¢ã1ã€ã®ãã¡ã€ã«ã«ãæ¥çãããããšã§æ§æãããæçµçã«ã¯index.htmlã®ãšã³ããªãã€ã³ãã«ãªããŸãã
2.ã©ã®ãããªå°é£ãçããŸããïŒ
- æåã®é£ããã¯ãããªããŒã¢ããªã±ãŒã·ã§ã³ã§ã¯ãªããã·ã¹ãã ãŠã£ãžã§ããã«ã©ãããããè€æ°ã®è€åã³ã³ããŒãã³ãïŒã¹ããŒãã³ã³ããŒãã³ã-CCãšåŒã³ãŸãããïŒãã€ãŸãåäžã®ãšã³ããªãã€ã³ãããªãããšã§ãã
- 2çªç®ã®é£ç¹ã¯ãã¢ããªã±ãŒã·ã§ã³ã®æäœäžã«ãããã®ãŠã£ãžã§ãããå«ãããŒãžããŸã£ããåŒã³åºãããªãå¯èœæ§ãããããšã§ãããããã£ãŠãçŸåšã®ã»ãã·ã§ã³ã§ã¯ãããªããŒã³ã¢èªäœã¯èšããŸã§ããªããããªããŒã³ã³ããŒãã³ãã¯äžåå¿ èŠãããŸããã
- 第äžã« ã1ã€ã®CCã¯ã¢ãããã¯ïŒ çŽ ã éãªã©ïŒã³ã³ããŒãã³ãã®1ã€ã®ã»ããïŒããããæããªã³ã³ããŒãã³ã-GKãšåŒã³ãŸãããïŒã䜿çšãããã1ã€ã¯å¥ã®ã»ããã䜿çšããŸãã ããã«ã亀差ç¹ãããå¯èœæ§ããããŸããã€ãŸãã2ã€ã®ç°ãªãUKãåãHAã䜿çšããŠããŸãã
3.ã©ãããã°è§£æ±ºã§ããŸããïŒ
æåã®è€éããèæ ®ããã°ãåè±åœãåå¥ã«å ç¡«ã§ããŸããã3çªç®ã®åé¡ããšããšãåãHAã®è€è£œãå¯èœã«ãªãã1åã®ã»ãã·ã§ã³ã§å°ãªããšã2ã€ã®è±åœã䜿çšãããç¶æ³ãèæ ®ãããšãããªããŒã³ã¢ã®è€è£œãå¿ ãååšããŸãã ãããã£ãŠãå¥ã®ãœãªã¥ãŒã·ã§ã³ãå¿ èŠã§ãã
2çªç®ã®è€éããèæ ®ããå Žåãæåã«CCã® 1ã€ã«ã¢ã¯ã»ã¹ãããšãã«ããªããŒã³ã¢ãšGKãäžåºŠã ãããŒããããããšã確èªããå¿ èŠãããã2çªç®ã«ã¢ã¯ã»ã¹ãããšãã«ããã¹ãŠãå床ããŠã³ããŒãããå¿ èŠã¯ãªãã CCèªäœãåçã«ããŒãããã ãã§ã
3çªç®ã®è€éããèæ ®ããå Žåãã¹ããŒãã³ã³ããŒãã³ãã§äœ¿çšããããã¹ãŠã®æããªã³ã³ããŒãã³ãã®ãªã¹ããäœæããå¿ èŠããããæçµçã«ã¯ããªããŒèªäœãšäžç·ã«å ç¡«ããŸãã
4. vulcanize-polymer-moduleã©ã€ãã©ãª
äžèšã®è«æã¯ãã¹ãŠãå ç¡«ããªããŒã¢ãžã¥ãŒã«ã©ã€ãã©ãªã®åœ¢ã§èšèšããŸããã
ããã«ã€ããŠãã£ãšã話ãããããšæããŸãã
4.1ã æ§é
vulcanize-polymer-module/
âââ imports.html
âââ vulcanize-utils.js
âââ rollup.config.js
âââ bower.json
âââ package.json
4.2ã bower.jsonã®èª¬æ
ãã®äžã§ãããªããŒã³ã¢èªäœãå«ããäŸåé¢ä¿ãšããŠå¿ èŠãªãã¹ãŠã®GCã«ã€ããŠèª¬æããŸãã
ããšãã°ã äŸåé¢ä¿ã»ã¯ã·ã§ã³ã¯æ¬¡ã®ããã«ãªããŸãã
äŸåé¢ä¿
ãäŸåé¢ä¿ãïŒ{ ãããªããŒãïŒãããªããŒ/ããªããŒïŒ^ 2.0.0ãã ãpolymer-reduxãïŒã^ 1.0.0ãã "iron-flex-layout"ïŒ "PolymerElements / iron-flex-layoutïŒ^ 2.0.0"ã "paper-button"ïŒ "PolymerElements / paper-buttonïŒ^ 2.0.0"ã "paper-badge"ïŒ "PolymerElements / paper-badgeïŒ^ 2.0.0"ã "paper-icon-button"ïŒ "PolymerElements / paper-icon-buttonïŒ^ 2.0.0"ã "paper-input"ïŒ "PolymerElements / paper-inputïŒ^ 2.0.0"ã "paper-item"ïŒ "PolymerElements / paper-itemïŒ^ 2.0.0"ã "paper-checkbox"ïŒ "PolymerElements / paper-checkboxïŒ^ 2.0.0"ã ãpaper-tabsãïŒãPolymerElements / paper-tabsïŒ^ 2.0.0ãã "paper-listbox"ïŒ "PolymerElements / paper-listboxïŒ^ 2.0.0"ã ãiron-a11y-keysãïŒãPolymerElements / iron-a11y-keysïŒ^ 2.0.0ãã "iron-list"ïŒ "PolymerElements / iron-listïŒ^ 2.0.0"ã "iron-icons"ïŒ "PolymerElements / iron-iconsïŒ^ 2.0.0"ã "paper-progress"ïŒ "PolymerElements / paper-progressïŒ^ 2.0.0"ã ãvaadin-split-layoutãïŒãvaadin / vaadin-split-layoutïŒ^ 2.0.0ãã ãvaadin-gridãïŒã^ 3.0.0ãã "iron-pages"ïŒ "PolymerElements / iron-pagesïŒ^ 2.0.0"ã ãé厩å£ãïŒãPolymerElements /é厩å£ïŒ^ 2.0.0ãã "iron-overlay-behavior"ïŒ "PolymerElements / iron-overlay-behaviorïŒ^ 2.0.0"ã ãvaadin-context-menuãïŒã^ 3.0.0ã }
ç§ã¯ããªããŒã§reduxã䜿çšããŠããããã polymer-reduxã©ã€ãã©ãªãå«ããŸããã
4.3ã Package.jsonã®èª¬æ
ããã«ã¯ããã«ãããå¿ èŠã®ããäŸåé¢ä¿ãç¹ã«åºåãã¡ã€ã«ã³ãŒãã®äžéã¯ãªãŒãã³ã°ã«äœ¿çšãããRollupJSãå«ãŸããŠããŸãã å ç¡«ã«äœ¿çšãããã³ãã³ãã«ã€ããŠã説æããŸãã詳ããèŠãŠã¿ãŸãããã
ã¹ã¯ãªãã
ãã¹ã¯ãªãããïŒ{ ããã«ããïŒãããŒã«ã¢ãã-cãã ãvulcanizeãïŒãvulcanize imports.html --inline-scripts --inline-css --strip-commentsãã ãrun-vulcanizeãïŒãnpm run vulcanize> imports.vulcanize.htmlãã "vulcanized"ïŒ "vulcanize imports.html --inline-scripts --inline-css --strip-comments | crisper --html imports.vulcanized.html --js imports.vulcanized.js> imports.vulcanized.html"ã "html-minifier"ïŒ "html-minifier imports.vulcanized.html --remove-optional-tags --collapse-whitespace --preserve-line-breaks -o imports.vulcanized.min.html"ã ãbuild-allãïŒãnpm run vulcanized && npm run build && npm run html-minifierã }
ããŒã ã䜿çšã®é åºãšåªå é äœïŒ
- build-allã¯ãå ç¡«ããã»ã¹å šäœãéå§ããã¡ã€ã³ããŒã ã§ãã
- vulcanized-å ç¡«èªäœ ãã€ãŸããã¹ãŠã®ã³ã³ããŒãã³ããšã«ãŒãã«ã1ã€ã®ãã¡ã€ã«ã«çµåããã¢ã»ã³ããªå šäœã.jsãã¡ã€ã«ãš.htmlãã¡ã€ã«ã«åå¥ã«åå²ããŸãïŒãŠãŒãã£ãªãã£vulcanizeãšcrisperã䜿çšãããŸã ïŒ
- build -js-fileã³ãŒããã³ã¡ã³ãããåé€ ïŒ RollupJSã䜿çšïŒ
- html-minifier -htmlãã¡ã€ã«ã®çž®å°ïŒ html-minifierã䜿çšïŒ
4.3.1ã ãŠãŒãã£ãªãã£ã®ã€ã³ã¹ããŒã«
ã芧ã®ãšãããå€ãã®è¿œå ãŠãŒãã£ãªãã£ã䜿çšãããŠããŸãããããã®ãŠãŒãã£ãªãã£ãæåã«ã·ã¹ãã ã«ã€ã³ã¹ããŒã«ããå¿ èŠããããŸãã
ãŠãŒãã£ãªãã£ã®ã€ã³ã¹ããŒã«
npm install -g vulcanize npm install -g crisper npm install -g html-minifier
4.3.2ã RollupJSãæ§æãã
ããŒã«ã¢ããã¯jsã³ãŒããã¯ãªãŒã³ã¢ããããããã«ã®ã¿äœ¿çšãããããã ããŒã«ã¢ããçšã«1ã€ã®ãã©ã°ã€ã³ã rollup-plugin-cleanupã®ã¿ã䜿çšããŸãã rollup-plugin-progressãã©ã°ã€ã³ã¯ ããã«ãããã»ã¹ãèŠèŠåããããã«äœ¿çšãããŸãã
rollup.config.js
import progress from 'rollup-plugin-progress'; import cleanup from 'rollup-plugin-cleanup'; export default { entry: 'imports.vulcanized.js', dest: 'imports.vulcanized.js', plugins: [ cleanup(), progress({ }), ] };
4.4ã vulcanize-utils.js
2çªç®ã®èŠä»¶ã解決ããããã«ãå®çšçãªã¡ãœããloadVulcanizedãäœæãããŸãããããã¯UKãããŒãããŸããããã®åã«å ç¡«ããããã¡ã€ã«ãããŠã³ããŒããã1åå®è¡ããŸããç¹°ãè¿ãåŒã³åºãã®å Žåã¯ã UKã®ã¿ãããŒãããŸãã
ãã®ãã©ã¡ãŒã¿ãŒãããã«è©³ããèããŠã¿ãŸãããã
loadVulcanized =é¢æ°ïŒurlãurlVulcanizedãã³ã³ãããŒã©ãŒãhtmlãã¹ãã¢ïŒ
- urlã¯ãã¹ããŒãã³ã³ããŒãã³ããžã®ãã¹ã§ãã ããã¯å¿ é ã§ãã
- urlVulcanizedã¯ãå ç¡«ãããã¢ã»ã³ããªãžã®ãã¹ã§ãã ããã©ã«ãã§ã¯ããã®ã¢ã»ã³ããªãžã®ãã¹ã¯../vulcanize-polymer-module/imports.vulcanized.min.htmlã§ãã
- ã³ã³ãããŒã©ãŒ -ç§ã®å Žåãããã¯ã·ã¹ãã ãŠã£ãžã§ããã®ã³ã³ãããŒã©ãŒã§ãã å¿ èŠã«å¿ããŠã
- html-ã¹ããŒãã³ã³ããŒãã³ãã®htmlãªããžã§ã¯ãã ã³ã³ãããŒã©ãŒãæå®ãããŠããå Žåã«æå³ããããŸãã
- store -reduxã¹ãã¢ã å¿ èŠã«å¿ããŠã
5.çµè«
ãã¡ããã build -cliã§Polymer-cliã䜿çšã§ããŸããããããã¢ã»ã³ãã«ãããšãpolymerãããžã§ã¯ãããã«ããããŠããããšãããããŸããè€æ°ã®<App />ã³ã³ãããŒã§ã³ã³ããŒãã³ãã䜿çšãããããåCCãåå¥ã«åéããå¿ èŠããããã¢ã»ã³ããªãã¡ã€ã«ã¯ããªããŒã³ã¢ãšè€åHAãéè€ããŠããŸãã ãããã£ãŠããã®èšäºã§èª¬æãããŠããã¢ãããŒãã¯ãããªããŒã«åºã¥ããã¹ãŠã®CCã®åäžã®ãšã³ããªãã€ã³ãã«ãããè€æ°ã®UIã©ã€ãã©ãªãäžç·ã«äœ¿çšããã·ã¹ãã ã§éåžžã«å¹æçã§ãã
å¯èœæ§ã®ããæ¬ ç¹ã®1ã€ã¯ãã·ã¹ãã ã§äœ¿çšããããã¹ãŠã®ACã®ãã¹ãŠã®GAãå«ãããäœæ¥ã»ãã·ã§ã³äžã«ãã¹ãŠã®ACã䜿çšã§ããããã§ã¯ãªããããå ç¡«ãã¡ã€ã«å ã®HAã®åé·æ§ãšèããããšãã§ããŸããå ç¡«ãã¡ã€ã«ãã¢ããããŒãããŸããã
ãŸããå°ãäžäŸ¿ãªããšã«ãæ°ããã³ã³ããŒãã³ããè¿œå ããåŸãã¢ã»ã³ããªãåèµ·åãããªããžããªãæŽæ°ïŒããã·ã¥ïŒããå¿ èŠããããä»ã®ãŠãŒã¶ãŒã¯bower updateã§ãã®ã©ã€ãã©ãªãæŽæ°ããå¿ èŠããããšããäºå®ãèæ ®ããããšãã§ããŸãã
ãã®ãã¹ãŠã«ããããããããã®ã©ã€ãã©ãªã¯ãã®ãããžã§ã¯ãã®åé¡ã解決ããŸããã€ãŸããä»ã®èª°ãã«ãšã£ãŠæçšã§ããå¯èœæ§ããããŸãã
ãã©ãŒã¯ ãããããã