Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Nuxt.jsで変わる開発フローとUniversal JavaScriptのイマ #jsfes

Nuxt.jsで変わる開発フローとUniversal JavaScriptのイマ #jsfes

2017.11.18 HANATANI Takuma(@potato4d) #jsfes

potato4d(Takuma HANATANI)

November 18, 2017
Tweet

More Decks by potato4d(Takuma HANATANI)

Other Decks in Programming

Transcript

  1. ࣗݾ঺հ )"/"5"/*5BLVNB • a.k.a. @potato4d • 1998/04/13 • ϑϦʔϥϯε •

    Programming • JavaScript(Vue, React), PHP(Plain, Laravel, Cake3) • Nuxt.js ࢓ࣄͰ࢖ͬͯ·͢ʂ • jp.vuejs.org translator • FRONTEND CONFERENCE 2017 Organizer
  2. 13

  3. ैདྷܕͷ443γεςϜ // Command $ npm start // Program … import

    { renderToString } from 'react-dom/server' … res.status(200).send(renderToString(ReactEl)); // Deps - Express - React - ReactDOM ReactDomϕʔεͰͷϨϯμϦϯά + ExpressͳͲͷFwͱͷ࿈ܞͰ࣮ݱ ΠϚυΩͷ։ൃͰ͸SSR͸ࣗ࡞͠ͳ͍͜ͱ͕ଟ͍
  4. ैདྷܕͷ443γεςϜ // Command $ npm start // Program … const

    renderer = require('vue-server- renderer').createRenderer() const { renderToString } = renderer … res.status(200).send(renderToString(VueEl)) // Deps - vue - vue-server-renderer - express vue-server-rendererͰͷϨϯμϦϯά + ExpressͳͲͷFwͱͷ࿈ܞͰ࣮ݱ ΠϚυΩͷ։ൃͰ͸SSR͸ࣗ࡞͠ͳ͍͜ͱ͕ଟ͍
  5. ΠϚυΩͷ443γεςϜ // Command $ npm start // Program /* ͳ͠(!)

    */ // Deps - next Next.jsʹ׬શʹ೚ͤΔ ΠϚυΩͷ։ൃͰ͸SSR͸ࣗ࡞͠ͳ͍͜ͱ͕ଟ͍
  6. ΠϚυΩͷ443γεςϜ // Command $ npm start // Program /* ͳ͠(!)

    */ // Deps - nuxt Nuxt.jsʹ׬શʹ೚ͤΔ ΠϚυΩͷ։ൃͰ͸SSR͸ࣗ࡞͠ͳ͍͜ͱ͕ଟ͍
  7. Nuxt.js ʹ͍ͭͯ 7VF։ൃΛࢧԉ͢ΔϑϩϯτΤϯυϑϨʔϜϫʔΫ w 7VF୯ମͰ͸ߏங͕൥ࡶͳػೳΛ·ͱΊͯఏڙ͢Δ w XFCQBDLϕʔεͷd&4จ๏ͷαϙʔτ w WVFϑΝΠϧϕʔεͷจ๏ͷαϙʔτ w

    4FSWFS4JEF3FOEFSJOH 443 Τϯδϯͷఏڙ w 44341"Ͱ6OJWFSTBMͳϧʔςΟϯάͷఏڙ w 7VFYετΞɾϓϥάΠϯɾϛυϧ΢ΣΞʹରԠ͠ ͨϓϩδΣΫτߏ੒ͷఏڙ w FUDʜ
  8. ैདྷͷίʔσΟϯάݱ৔ͷͭΒ͞ ଏʹݴ͏SPA԰͞Μͳੈք؍ ଏʹݴ͏Web੍࡞ͳੈք؍ - ೝূલఏͳੈքͳͷͰSEO͸ෆཁ - ඞཁʹͳͬͯΑ͏΍͘SSRΛݕ౼Ͱྑ͍ - શମతͳϓϩάϥϛϯάεΩϧ͸ߴ͍ -

    Ͱ͖Δ͔͗ΓίʔσΟϯάۀ຿͸ϝΠϯ ʹਾ͑ͨ͘ͳ͍ - จݴ΍SEO/OGP͸ඇৗʹॏཁ - ൺֱతJSπʔϧ΁ͷཧղ͕ઙ͍ਓΛ ର৅ͱͨ͠ΤίγεςϜͷܗ੒ - ϓϩάϥϛϯάతͳཁૉ͸ബ͍෺͕ଟ͍
  9. ैདྷͷίʔσΟϯάݱ৔ͷͭΒ͞ ଏʹݴ͏SPA԰͞Μͳੈք؍ ଏʹݴ͏Web੍࡞ͳੈք؍ - ೝূલఏͳੈքͳͷͰSEO͸ෆཁ - ඞཁʹͳͬͯΑ͏΍͘SSRΛݕ౼Ͱྑ͍ - શମతͳϓϩάϥϛϯάεΩϧ͸ߴ͍ -

    Ͱ͖Δ͔͗ΓίʔσΟϯάۀ຿͸ϝΠϯ ʹਾ͑ͨ͘ͳ͍ - จݴ΍SEO/OGP͸ඇৗʹॏཁ - ൺֱతJSπʔϧ΁ͷཧղ͕ઙ͍ਓΛ ର৅ͱͨ͠ΤίγεςϜͷܗ੒ - ϓϩάϥϛϯάతͳཁૉ͸ബ͍෺͕ଟ͍ SPA԰͞Μ͕ίʔσΟϯάΛ͢Δඞཁੑͷൃੜ
  10. ैདྷͷίʔσΟϯάݱ৔ͷͭΒ͞ ଏʹݴ͏SPA԰͞Μͳੈք؍ ଏʹݴ͏Web੍࡞ͳੈք؍ - ೝূલఏͳੈքͳͷͰSEO͸ෆཁ - ඞཁʹͳͬͯΑ͏΍͘SSRΛݕ౼Ͱྑ͍ - શମతͳϓϩάϥϛϯάεΩϧ͸ߴ͍ -

    Ͱ͖Δ͔͗ΓίʔσΟϯάۀ຿͸ϝΠϯ ʹਾ͑ͨ͘ͳ͍ - จݴ΍SEO/OGP͸ඇৗʹॏཁ - ൺֱతJSπʔϧ΁ͷཧղ͕ઙ͍ਓΛ ର৅ͱͨ͠ΤίγεςϜͷܗ੒ - ϓϩάϥϛϯάతͳཁૉ͸ബ͍෺͕ଟ͍ SPA԰͞Μ͕ίʔσΟϯάΛ͢Δඞཁੑͷൃੜ ɾίϯϙʔωϯτࢤ޲Ͱ૊ΜͰ͓͖͍ͨ ɾGulp + pug + …Έ͍ͨͳߏ੒Λߋ৽͍ͨ͠ ɾϩδοΫ͕ඞཁͳՕॴ͸FwΛ࢖͍͍ͨ
  11. ैདྷͷίʔσΟϯάݱ৔ͷͭΒ͞ ଏʹݴ͏SPA԰͞Μͳੈք؍ ଏʹݴ͏Web੍࡞ͳੈք؍ - ೝূલఏͳੈքͳͷͰSEO͸ෆཁ - ඞཁʹͳͬͯΑ͏΍͘SSRΛݕ౼Ͱྑ͍ - શମతͳϓϩάϥϛϯάεΩϧ͸ߴ͍ -

    Ͱ͖Δ͔͗ΓίʔσΟϯάۀ຿͸ϝΠϯ ʹਾ͑ͨ͘ͳ͍ - จݴ΍SEO/OGP͸ඇৗʹॏཁ - ൺֱతJSπʔϧ΁ͷཧղ͕ઙ͍ਓΛ ର৅ͱͨ͠ΤίγεςϜͷܗ੒ - ϓϩάϥϛϯάతͳཁૉ͸ബ͍෺͕ଟ͍ SPA԰͞Μ͕ίʔσΟϯάΛ͢Δඞཁੑͷൃੜ ɾSEOతʹJS-Fw͸࢖͑ͳ͍ ɾES2015஌ࣝͷนɾελοΫͷॏ͞ ɾલఏπʔϧ͕ଟ͗͢ΔͷͰΤΰʹͳΓ͕ͪ ɾSSR͢Δ΄Ͳ͸ίετ͔͚ΒΕͳ͍
  12. NuxtͰগͣͭ͠վળ͍ͯ͘͠ݱ৔ ଏʹݴ͏SPA԰͞Μͳੈք؍ ଏʹݴ͏Web੍࡞ͳੈք؍ - ೝূલఏͳੈքͳͷͰSEO͸ෆཁ - ඞཁʹͳͬͯΑ͏΍͘SSRΛݕ౼Ͱྑ͍ - શମతͳϓϩάϥϛϯάεΩϧ͸ߴ͍ -

    Ͱ͖Δ͔͗ΓίʔσΟϯάۀ຿͸ϝΠϯ ʹਾ͑ͨ͘ͳ͍ - จݴ΍SEO/OGP͸ඇৗʹॏཁ - ൺֱతJSπʔϧ΁ͷཧղ͕ઙ͍ਓΛ ର৅ͱͨ͠ΤίγεςϜͷܗ੒ - ϓϩάϥϛϯάతͳཁૉ͸ബ͍෺͕ଟ͍
  13. NuxtͰগͣͭ͠վળ͍ͯ͘͠ݱ৔ ଏʹݴ͏SPA԰͞Μͳੈք؍ ଏʹݴ͏Web੍࡞ͳੈք؍ - ೝূલఏͳੈքͳͷͰSEO͸ෆཁ - ඞཁʹͳͬͯΑ͏΍͘SSRΛݕ౼Ͱྑ͍ - શମతͳϓϩάϥϛϯάεΩϧ͸ߴ͍ -

    Ͱ͖Δ͔͗ΓίʔσΟϯάۀ຿͸ϝΠϯ ʹਾ͑ͨ͘ͳ͍ - จݴ΍SEO/OGP͸ඇৗʹॏཁ - ൺֱతJSπʔϧ΁ͷཧղ͕ઙ͍ਓΛ ର৅ͱͨ͠ΤίγεςϜͷܗ੒ - ϓϩάϥϛϯάతͳཁૉ͸ബ͍෺͕ଟ͍ SPA԰͞Μ͕ίʔσΟϯάΛ͢Δඞཁੑͷൃੜ
  14. NuxtͰগͣͭ͠վળ͍ͯ͘͠ݱ৔ ଏʹݴ͏SPA԰͞Μͳੈք؍ ଏʹݴ͏Web੍࡞ͳੈք؍ - ೝূલఏͳੈքͳͷͰSEO͸ෆཁ - ඞཁʹͳͬͯΑ͏΍͘SSRΛݕ౼Ͱྑ͍ - શମతͳϓϩάϥϛϯάεΩϧ͸ߴ͍ -

    Ͱ͖Δ͔͗ΓίʔσΟϯάۀ຿͸ϝΠϯ ʹਾ͑ͨ͘ͳ͍ - จݴ΍SEO/OGP͸ඇৗʹॏཁ - ൺֱతJSπʔϧ΁ͷཧղ͕ઙ͍ਓΛ ର৅ͱͨ͠ΤίγεςϜͷܗ੒ - ϓϩάϥϛϯάతͳཁૉ͸ബ͍෺͕ଟ͍ SPA԰͞Μ͕ίʔσΟϯάΛ͢Δඞཁੑͷൃੜ ɾ੩తॻ͖ग़͠ʹΑͬͯSEO໰୊͸ղফ ɾES࣌୅ͷ஌ࣝ͸࠷௿ݴޠจ๏͚ͩͰOK ɾඞཁͳπʔϧ͸ҰͭͷΈͰ׬͍݁ͯ͠Δ ɾSSR͸ͦ΋ͦ΋ෆཁ
  15. 13