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

Vue.js入門1ヶ月で自作の技術ブログをリリースした話

subroh_0508
October 17, 2019

 Vue.js入門1ヶ月で自作の技術ブログをリリースした話

Yumemi.vue #2の10分枠LT資料です。
https://yumemi.connpass.com/event/148953/

技術ブログ: https://subroh0508.net
Github: https://github.com/subroh0508/techblog

subroh_0508

October 17, 2019
Tweet

More Decks by subroh_0508

Other Decks in Technology

Transcript

  1. ࡞ͬͨϞϊ w ԣਢլୈ؅۠৘ใہ w 7VFKT 8FCQBDL w WVFSPVUFSΛ࢖ͬͨ41" w 4&0ରࡦͱͯ͠443

    w WVFTFSWFSSFOEFSFS w &YQSFTTKT ϦϯΫTVCSPIOFU (JUIVCTVCSPIUFDICMPH
  2. ࣮૷ղઆ σΟϨΫτϦߏ੒ w "UPNJD%FTJHOͬΆ͍ߏ੒ BUPNTNPMFDVMFT w υϝΠϯʹґଘ͠ͳ͍$PNQPOFOU w ྫ0VUMJOFE#VUUPOɺ4IBSF#VUUPO QBHFT

    w 63-ͱରͷରԠ͕औΕΔը໘ PSHBOJTNTUFNQMBUFT w ͦΕҎ֎ ࠶ར༻ੑͦ͜·Ͱߴ͘ͳ͍$PNQPOFOU
  3. ݪҼௐࠪ w NFUBλάͷߋ৽ॲཧ w "QQWVFͷNPVOUFE ͱ SPVUFΦϒδΣΫτͷߋ৽ͰൃՐ w ௚઀هࣄϖʔδʹΞΫηεͨ͠৔߹ɺ λάߋ৽લͷ)5.-͕ಡ·Εͯ͠·͏

    ˠॳظঢ়ଶͷNFUBλά͕γΣΞ࣌ʹ൓өʂ export default { ... mounted() { updateConfig(this.$route); insertMetaTags(this.$route); }, watch: { '$route': function (to, from) { updateConfig(to); insertMetaTags(to); } } } 41"։ൃͷৗࣝͰ͸ʁ ΅͘ɺ"OESPJEΤϯδχΞ΍͠ʜ
  4. ରࡦ w WVFTFSWFSSFOEFSFSΛ࢖ͬͨ4FSWFS4JEF3FOEFSJOH w ެࣜΨΠυIUUQTTTSWVFKTPSH w ରԠखॱ w 7VFΠϯελϯεͷॳظԽΛؔ਺Խ w

    ΫϥΠΞϯτ༻αʔόʔ༻ͷΤϯτϦϑΝΠϧΛ࡞੒ w αʔόʔ༻ͷόϯυϧ+40/ͷੜ੒ w &YQSFTTKT WVFTFSWFSSFOEFSFSͰOPEFKTαʔόʔΛ࣮૷
  5. ରԠखॱ w 7VFΠϯελϯεͷॳظԽΛؔ਺Խ export const createApp = () => {

    const router = createRouter(); const app = new Vue({ router, render: h => h(App), }); return { app, router }; }; new Vue({ router, el: '#app', components: { App }, template: '<app/>', }); CFGPSF BGUFS
  6. ରԠखॱ w ΫϥΠΞϯτ༻αʔόʔ༻ͷΤϯτϦϑΝΠϧΛ࡞੒ FOUSZDMJFOUKT FOUSZTFSWFSKT const { app, router }

    = createApp(); router.onReady(() => { app.$mount('#app'); }); export default (context) => { return new Promise((resolve, reject) => { const { app, router } = createApp(); router.push(context.url); router.onReady(() => { resolve(app); }); }); }; ˞8FCQBDLͷFOUSZʹࢦఆ͢ΔϑΝΠϧ
  7. ରԠखॱ w αʔόʔ༻ͷόϯυϧ+40/ͷੜ੒ w 7VF4434FSWFS1MVHJOΛ௥Ճ w ZBSOSVOXFCQBDL࣮ߦ w TFWFSCVOEMFKTPO͕ੜ੒ module.exports

    = merge(common, { ... plugins: [ ... new VueSSRServerPlugin({ filename: 'server-bundle.json', }), ], }); XFCQBDLTFSWFSKT
  8. ରԠखॱ w &YQSFTTKT WVFTFSWFSSFOEFSFSͰOPEFKTαʔόʔΛ࣮૷ TFSWFSKT const renderer = createBundleRenderer(serverBundle, {

    template }); const app = express(); app.get('*', (req, res) => { const context = { ...metatags(req.path, req.query), url: req.url }; renderer.renderToString(context, (error, html) => { res.end(html); }); }); app.listen(port, () => console.log('Server start: 8080'));
  9. ରԠखॱ w &YQSFTTKT WVFTFSWFSSFOEFSFSͰOPEFKTαʔόʔΛ࣮૷ TFSWFSKT const renderer = createBundleRenderer(serverBundle, {

    template }); const app = express(); app.get('*', (req, res) => { const context = { ...metatags(req.path, req.query), url: req.url }; renderer.renderToString(context, (error, html) => { res.end(html); }); }); app.listen(port, () => console.log('Server start: 8080')); લͷखॱͰੜ੒ͨ͠+40/
  10. ରԠखॱ w &YQSFTTKT WVFTFSWFSSFOEFSFSͰOPEFKTαʔόʔΛ࣮૷ TFSWFSKT const renderer = createBundleRenderer(serverBundle, {

    template }); const app = express(); app.get('*', (req, res) => { const context = { ...metatags(req.path, req.query), url: req.url }; renderer.renderToString(context, (error, html) => { res.end(html); }); }); app.listen(port, () => console.log('Server start: 8080')); NFUBλάੜ੒ؔ਺
  11. ରԠखॱ w &YQSFTTKT WVFTFSWFSSFOEFSFSͰOPEFKTαʔόʔΛ࣮૷ TFSWFSKT const renderer = createBundleRenderer(serverBundle, {

    template }); const app = express(); app.get('*', (req, res) => { const context = { ...metatags(req.path, req.query), url: req.url }; renderer.renderToString(context, (error, html) => { res.end(html); }); }); app.listen(port, () => console.log('Server start: 8080')); DPOUFYUͱόϯυϧ+40/͔Β ΠΠײ͡ʹ)5.-ੜ੒ͯ͘͠ΕΔؔ਺