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
Astro の pros / cons
Search
hashiba daiki
April 21, 2023
Programming
1
1.3k
Astro の pros / cons
Vercel * Astro を使った開発を行い気づいた点を共有します。
hashiba daiki
April 21, 2023
Tweet
Share
More Decks by hashiba daiki
See All by hashiba daiki
フロントエンドの大規模開発におけるTips
hashibadaiki
3
1.3k
Other Decks in Programming
See All in Programming
Flutterでllama.cppをつかってローカルLLMを試してみた
sakuraidayo
0
150
REALITY コマンド作成チュートリアル
nishiuriraku
0
120
The Missing Link in Angular’s Signal Story: Resource API and httpResource
manfredsteyer
PRO
0
150
知識0からカンファレンスやってみたらこうなった!
syossan27
5
270
ビカム・ア・コパイロット
ymd65536
1
140
“技術カンファレンスで何か変わる?” ──RubyKaigi後の自分とチームを振り返る
ssagara00
0
120
最速Green Tea 🍵 Garbage Collector
kuro_kurorrr
1
130
開発者フレンドリーで顧客も満足?Platformの秘密
algoartis
0
230
個人開発の学生アプリが企業譲渡されるまで
akidon0000
2
1.2k
実践Webフロントパフォーマンスチューニング
cp20
45
10k
20250429 - CNTUG Meetup #67 / DevOps Taiwan Meetup #69 - Deep Dive into Tetragon: Building Runtime Security and Observability with eBPF
tico88612
0
180
Serving TUIs over SSH with Go
caarlos0
0
720
Featured
See All Featured
How to Think Like a Performance Engineer
csswizardry
23
1.6k
Fireside Chat
paigeccino
37
3.4k
Scaling GitHub
holman
459
140k
Being A Developer After 40
akosma
91
590k
KATA
mclloyd
29
14k
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3.2k
How to train your dragon (web standard)
notwaldorf
91
6k
Producing Creativity
orderedlist
PRO
344
40k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
5
570
Embracing the Ebb and Flow
colly
85
4.7k
The Invisible Side of Design
smashingmag
299
50k
Stop Working from a Prison Cell
hatefulcrawdad
268
20k
Transcript
Vercel * Astroで気づいた Astro のpros / cons Serverless Frontend Meetup
#2 「Vercel」 2023/4/21 はしば
自己紹介 - 羽柴 大生(はしば だいき) - chot Inc. 所属 -
Web フロントエンドエンジニア - 大阪出身→香川在住 - (世界一)可愛い娘がいます
今回話すこと # Astroのこと - 概要 - できること - 実際にやったこと -
pros / cons - まとめ
何を伝えたいか - フロントエンドは流行り廃りがしんどい - できることは見つけられても、できないことはなかなか見 当たらない - できることと、できないこと、実際に触って気づいたことを ベースに話します
概要(公式引用) - Astro is the all-in-one web framework designed for
speed. Pull your content from anywhere and deploy everywhere, all powered by your favorite UI components and libraries. - zero-JS - Content-focused https://astro.build/
できること - blog - portfolio - corporate - EC
できること? - blog - portfolio - corporate - EC
できる範囲 - blog - portfolio - corporate - EC
- blog … all pre-renderであれば - portfolio … all pre-renderであれば
- corporate - EC できる範囲
- blog … all pre-renderであれば - portfolio … all pre-renderであれば
- corporate … ぎりぎり - EC できる範囲
- blog … all pre-renderであれば - portfolio … all pre-renderであれば
- corporate … ぎりぎり - EC … 🥺 できる範囲?
demo(blog) / : Top page … pre-render /search : 検索ページ
… SSR /blog/[blogId] : ブログ詳細 … pre-render
実際にやったこと - HTML / CSSが静的なassetとして欲しい - JSを不用意に吐き出さない - human readableなコードが欲しい
- previewを見せる必要がある - 非エンジニアでも確認できる環境 → Vercel * Astro
良かったこと - jQueryをぬるっと入れれる - それがアンチパターンかどうかは一旦おいておいて - jsxのお作法や、v-forみたいな呪文を覚えなくても素のHTML の知識があれば対応できる - モダンフロント初めての人でも障壁が少ないように感じた
(TSもmustではない)
つらかったこと① 沢山の getElementById, addEventListener useState1行でも使うとn千行のjs fileが爆誕してしまうため、islands architecture が導入できない。 (zero-JSという特徴が死ぬ) 最初は書きやすいと思った
.astro fileが敵に見えてくる。
つらかったこと① 公式には「こう書いたらuseStateなくてもいけるで」って書いてますが、こう書きた くないから皆 React やら Vue やらを使ってるんやで https://docs.astro.build/en/guides/client-side-scripts/
つらかったこと② script, style tagが独特 - 暗黙的にglobalかinlineかが決まっている - コンポーネントの出し分けなどで中々意図した挙動にさせずらい - <script>タグにtype="module
"またはsrc以外の属性を追加すると、 Astroのデフォルトのバンドル動作が無効になり、is:inlineディレクティ ブがあるかのようにタグが扱われる
つらかったこと② script, style tagが独特 - 一応front matterから変数を渡すこともできるが、渡せる変数も 限られている(JSONでシリアライズ可能な値のみ)
つらかったこと③ いつも通りの eslint, TS ではない 当然と言えば当然ですが、 - JSX.IntrinsicElements['div'] - CSSProperties
- ReactNode などは存在しない。ReactがTSと親和性がありすぎる
つらかったこと④ 謎の挙動がある - 開発サーバーが急にこける - たまにeslintが通らない(同じコードで確認したら通るとかも ある) - buildも同様
つらかったこと④ 謎の挙動がある - 開発サーバーが急にこける - たまにeslintが通らない(同じコードで確認したら通るとかも ある) - buildも同様 →総じてReactに比べると開発者体験が辛かった🥺
ワンポイント ※特に静的なassetが欲しい場合 ・distされたデータをよく確認する ・npm scriptに頼る ・Vercelにdeployされている時とlocalの distされるデータは違う
まとめ ①静的なfileを手に入れたい ②all pre-render で簡素なサイト ③ejsの代わり(未検証)
まとめ ①静的なfileを手に入れたい ②all pre-render で簡素なサイト ③ejsの代わり(未検証) →これ以外は React, Vue などが使えるなら素直にそっち
参考 なんだかんだ公式 https://astro.build/ script tagの挙動について https://hiroppy.me/blog/astro-script-issue Astroのサンプルコードやversion2の紹介動画 https://www.youtube.com/watch?v=gi4c7fbeURc
ご視聴 & ご清聴 ありがとうございました!!!