Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
v-tokyo #13 6月16日
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
James
June 16, 2021
Programming
130
1
Share
v-tokyo #13 6月16日
ViteでStatic Site Generatorの事例について
James
June 16, 2021
Other Decks in Programming
See All in Programming
2026-03-27 #terminalnight 変数展開とコマンド展開でターミナル作業をスマートにする方法
masasuzu
0
320
Rethinking API Platform Filters
vinceamstoutz
0
11k
YJITとZJITにはイカなる違いがあるのか?
nakiym
0
200
「接続」—パフォーマンスチューニングの最後の一手 〜点と点を結ぶ、その一瞬のために〜
kentaroutakeda
5
2.5k
煩雑なSkills管理をSoC(関心の分離)により解決する――関心を分離し、プロンプトを部品として育てるためのOSSを作った話 / Solving Complex Skills Management Through SoC (Separation of Concerns)
nrslib
4
850
Radical Imagining - LIFT 2025-2027 Policy Agenda
lift1998
0
250
Codex CLIのSubagentsによる並列API実装 / Parallel API Implementation with Codex CLI Subagents
takatty
2
890
Nuxt Server Components
wattanx
0
260
Reactive ❤️ Loom: A Forbidden Love Story
franz1981
2
230
それはエンジニアリングの糧である:AI開発のためにAIのOSSを開発する現場より / It serves as fuel for engineering: insights from the field of developing open-source AI for AI development.
nrslib
1
840
Go_College_最終発表資料__外部公開用_.pdf
xe_pc23
0
180
Vibe NLP for Applied NLP
inesmontani
PRO
0
310
Featured
See All Featured
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.1k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.2k
The Spectacular Lies of Maps
axbom
PRO
1
690
The Illustrated Children's Guide to Kubernetes
chrisshort
51
52k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
First, design no harm
axbom
PRO
2
1.2k
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.1k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
9.9k
Making Projects Easy
brettharned
120
6.6k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
140
Scaling GitHub
holman
464
140k
Transcript
Vite でSSG の本番運用をやってみた 事例:特定保健指導サービスの紹介ページ JAMES ROBERTS v-tokyo #13 2021-06-16
James Roberts robjamdev Frontend Engineer @MedPeer Vue, Typescript, Cloud Architecture
が大好き 自炊も大好き🌮
特定保健指導サービスは 食事・運動等の生活の習慣を見直して、生活習慣病の発症リスクを低減させる国の制度 専門職(管理栄養士、保健師)と共に目標を立て、数カ月の支援を受ける。
紹介ページ(before) アナログなオペレーション… ユーザー(利用店舗)より電話で変更依頼 弊社スタッフは手動編集 電話で変更確認 全て、自動化! 紹介ページは外部のWeb ページ作成サービスを利用 特定保険指導の予約可能の店舗(350+) 情報を表示
紹介ページ Architecture (after) ユーザー(利用店舗)が店舗の情報を自分で編集 紹介ページを更新する API Server がLambda(Vite のSSG) を実行する
Lambda の実行の内容 html をrender する script を削除する Client Side Hydration のfragment 削除する 生成した結果をS3 に保存
なぜVite? prerendering(SSR) が必要 本体のproject はNuxtJs なのでに移行しやすい Vite で検証できるプロジェクト Vite は早いから
Vite のSSR `main.js` にLambda のイベントデータを渡す NodeJs の環境でrequire のimport が必須 `provide/inject`
で `App.vue` に参照できるようにする Vite dev の場合はES6 のimport で良い https://Vitejs.dev/guide/ssr.html 開発時点 v1.0.0-rc13 ` ` export const createApp = (context) => { // main.js if (isSSR) { const app = createSSRApp(App); app.provide('subdomain', context.subdomain); // ... return app; } else { const app = createClientApp(App); app.provide('subdomain', context.subdomain); return app; } } if(!isSSR) { createApp(context).mount('#app'); }
Vite のSSR からSSG Lambda の入り口 先の `main.js` の createApp SSR
のコンテンツ 正規表現で必要ないものを削除する 開発時点 v1.0.0-rc13 ` ` exports.handler = async (event) => { const renderer = require('@vue/server-renderer'); const { createApp } = require('ssr/_assets/index.js'); const app = createApp(event); const content = await renderer.renderToString(app); content.replace(/<!--[\[-\]]-->/g, ''); // js script を削除する // S3 にupload }
まとめ 顧客と弊社スタッフの高評価 PaaS で最適なソリューションはよかった Vite がいいぞ!(V2 だともっと簡単) Vite でserverless はいい感じ!
Credits スライドはslidev で作りました🎉 スライド: https://speakerdeck.com/robjam/v-tokyo-6yue-16ri エンジニア募集しています! ありがとうございます