Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
v-tokyo #13 6月16日
Search
James
June 16, 2021
Programming
1
120
v-tokyo #13 6月16日
ViteでStatic Site Generatorの事例について
James
June 16, 2021
Tweet
Share
Other Decks in Programming
See All in Programming
ハイパーメディア駆動アプリケーションとIslandアーキテクチャ: htmxによるWebアプリケーション開発と動的UIの局所的適用
nowaki28
0
430
マスタデータ問題、マイクロサービスでどう解くか
kts
0
110
20251212 AI 時代的 Legacy Code 營救術 2025 WebConf
mouson
0
200
Pythonではじめるオープンデータ分析〜書籍の紹介と書籍で紹介しきれなかった事例の紹介〜
welliving
1
270
AI時代を生き抜く 新卒エンジニアの生きる道
coconala_engineer
1
350
Flutter On-device AI로 완성하는 오프라인 앱, 박제창 @DevFest INCHEON 2025
itsmedreamwalker
1
130
AIエージェントを活かすPM術 AI駆動開発の現場から
gyuta
0
440
Graviton と Nitro と私
maroon1st
0
110
Go コードベースの構成と AI コンテキスト定義
andpad
0
130
TestingOsaka6_Ozono
o3
0
170
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
200
Developing static sites with Ruby
okuramasafumi
0
310
Featured
See All Featured
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
39
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
280
A Modern Web Designer's Workflow
chriscoyier
698
190k
A Tale of Four Properties
chriscoyier
162
23k
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
63
35k
Amusing Abliteration
ianozsvald
0
63
We Have a Design System, Now What?
morganepeng
54
7.9k
Getting science done with accelerated Python computing platforms
jacobtomlinson
0
72
Docker and Python
trallard
47
3.7k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
320
Producing Creativity
orderedlist
PRO
348
40k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
32
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 エンジニア募集しています! ありがとうございます