Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
v-tokyo #13 6月16日
Search
James
June 16, 2021
Programming
130
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
v-tokyo #13 6月16日
ViteでStatic Site Generatorの事例について
James
June 16, 2021
Transcript
10 slides
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 エンジニア募集しています! ありがとうございます
Other Decks in Programming
See All in Programming
AIエージェントの「テストは通るのに本番で壊れる」を減らす
shibuiwilliam
3
130
SONY CISC-NEWS NWS-1750 + NWB-225 ハードウェアメンテとフレームバッファカラー対応 / KOF2026
tsutsui
0
150
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
240
ローカルLLMの基本と近況 2611 / Local LLM basics and recent situation 2611
kishida
3
680
Getting Started with Vibe Coding
miccheng
0
260
あなたはMCPの機能を、まだ知らない。
4geru
1
760
baseline으로 마이그레이션, 리팩토링 안전하게 맡기기
fornewid
1
1.1k
Kotlin Fest 2026: Kotlin コンパイラに Contribute してみよう! - Kotlin/Wasm で深い再帰を書けるようにした話
ternbusty
1
440
Spec-driven Development with AI
simas
PRO
0
2.3k
エラーチャンネルのボールを拾い続けて鍛えるエンジニアの地力 / phpcon-niigata2026
meihei3
1
590
Kiro Crewによる開発体験ーKiro CrewでStrands Decider 2B に関する技術検証をやってみた
satoshi256kbyte
1
240
AWS CDKを理解するために公式の定義を深掘って解説してみる / Understanding AWS CDK by Digging into Its Official Definition
akihisaikeda
3
360
Featured
See All Featured
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
680
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
50
10k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
670
Test your architecture with Archunit
thirion
2
2.5k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
650
The Pragmatic Product Professional
lauravandoore
37
7.5k
Un-Boring Meetings
codingconduct
0
520
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3.1k
It's Worth the Effort
3n
188
30k
For a Future-Friendly Web
brad_frost
184
11k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
2
2.1k
A designer walks into a library…
pauljervisheath
211
25k