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
Angularの静的サイトジェネレーター「Scully」の最新情報
Search
puku0x
October 17, 2020
Technology
380
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Angularの静的サイトジェネレーター「Scully」の最新情報
puku0x
October 17, 2020
More Decks by puku0x
See All by puku0x
新メンバーのために、シニアエンジニアが環境を作る時代
puku0x
0
1.5k
Agent Skills 入門
puku0x
0
1.9k
ファインディにおけるフロントエンド技術選定の歴史
puku0x
2
2.1k
生成AIではじめるテスト駆動開発
puku0x
0
1.4k
実践!カスタムインストラクション&スラッシュコマンド
puku0x
2
3.3k
Nx × AI によるモノレポ活用 〜コードジェネレーター編〜
puku0x
0
1.7k
ファインディにおけるフロントエンド技術選定の歴史
puku0x
2
310
ファインディでのGitHub Actions活用事例
puku0x
9
3.9k
Findyの開発生産性向上への取り組み ~Findyフロントエンドの場合~
puku0x
0
490
Other Decks in Technology
See All in Technology
生成AIの活用/high_school2026
okana2ki
0
130
「最後に責任を取るのはチーム」— 人間のPRレビューを最小化してアップデートしたメンタルモデル
jnishime_dresscode
0
550
Kaggleで成長するために意識したこと
prgckwb
2
310
ボーイスカウトルールでメモリやスキルを改善しよう
azukiazusa1
1
700
個人開発で育てる「大規模設計の苗床」 - AI時代の1人開発から始める業務への知識接続 / The Seedbed for Large-Scale Design - From AI-Era Solo Projects to Professional Knowledge
bitkey
PRO
0
150
非定型なドキュメントを効率よくリファクタする 〜えぇ!?仕様書27本の移行が1日で終わったって!?〜
subroh0508
1
280
ADDF - ループエンジニアリングするフレームワークを作ったら/I Didn't Set Out to Build Loop Engineering, But ADDF Did
fruitriin
0
120
Foxgloveについて 実際にExtensionを開発して公開するまでの話 / About Foxglove: The Story of Developing and Releasing an Extension
ry0_ka
0
210
CIで使うClaude
iwatatomoya
0
240
Compose 新機能総まとめ / What's New in Jetpack Compose
yanzm
0
160
Claude Codeとハーネスについて考えてみる
oikon48
18
9.3k
実装だけじゃない! CCA-F取得エンジニアが教えるClaude Code開発プロセス活用術
diggymo
2
640
Featured
See All Featured
Darren the Foodie - Storyboard
khoart
PRO
3
3.4k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.5k
Fireside Chat
paigeccino
42
4k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
201
75k
Between Models and Reality
mayunak
4
370
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
190
New Earth Scene 8
popppiees
3
2.4k
A designer walks into a library…
pauljervisheath
211
24k
Building the Perfect Custom Keyboard
takai
2
810
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
210
Git: the NoSQL Database
bkeepers
PRO
432
67k
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
630
Transcript
Angularの静的サイトジェネレーター 「Scully」の最新情報 GDG DevFest 2020 @puku0x Noriyuki Shinpuku
Noriyuki Shinpuku ng-fukuoka organizer VEGA corporation Co., Ltd. @puku0x 2
@puku0x SSG流行ってる 3 Gridsome VuePress Nuxt.js Next.js Gatsby
@puku0x Angularは...? 4
@puku0x Scully • Angular用のSSG(静的サイトジェネレータ) 5 https://scully.io/ 9月にv1.0.0 リリース
@puku0x 仕組み • Angularアプリケーションを Puppeteer で実行 ◦ HttpClient等の通信完了を確認して出力 ◦ PLATFORM_IDが常にブラウザー
• 実行時はプリレンダされたHTML → 読み込み完了で Angularアプリケーションに置き換わる 6
$ ng new my-app --routing $ cd my-app $ ng
add @scullyio/init インストール 7
$ ng g @scullyio/init:blog $ ng g @scullyio/init:post --name="New Post"
ブログ作成 8
import { ScullyConfig } from '@scullyio/scully'; export const config: ScullyConfig
= { projectRoot: './src', projectName: my-app, outDir: './dist/static', routes: { … }, defaultPostRenderers: [], }; 設定ファイル 9
export const config: ScullyConfig = { routes: { '/users/:userId': {
type: 'json', userId: { url: 'https://jsonplaceholder.typicode.com/users', property: 'id', }, }, }, }; 動的コンテンツのプリレンダ 10
export const config: ScullyConfig = { routes: { '/blog/:slug': {
type: 'contentFolder', slug: { folder: './blog, }, }, }, }; ファイルからページ生成 11
constructor(private srs: ScullyRoutesService) {} post$ = this.srs.getCurrent().pipe( map((route: ScullyRoute) =>
({ title: route.title || route.route, description: route.description, slug: route.slug, })), shareReplay(1) ); ScullyRoutesService 12
$ ng build --prod $ npx scully --RSD --scan --prod
$ npm run scully:serve Angular distribution server started on “http://localhost:1864/” Scully static server started on “http://localhost:1668/” 実行 13
$ ng build --watch 開発 14 $ npx scully --watch
import { setPluginConfig } from '@scullyio/scully'; import { MarkedConfig }
from '@scullyio/scully/lib/fileHanderPlugins/markdown'; setPluginConfig<MarkedConfig>('md', { enableSyntaxHighlighting: true, }); シンタックスハイライト 15
import { ScullyConfig } from '@scullyio/scully'; export const config: ScullyConfig
= { … defaultPostRenderers: ['seoHrefOptimise'], }; リンクに末尾スラッシュ追加 16
$ npm i -D @scullyio/plugins-scully-plugin-remove-scripts $ ng build --prod <script>タグ削除
17 import { ScullyConfig, setPluginConfig } from '@scullyio/scully'; import { removeScripts, RemoveScriptsConfig } from '@scullyio/plugins-scully-plugin-remove-scripts'; setPluginConfig<RemoveScriptsConfig>(removeScripts, { keepTransferstate: false }); export const config: ScullyConfig = { defaultPostRenderers: [removeScripts], };
$ npm i -D @scullyio/scully-plugin-critical-css 不要なCSS削除 18 import { ScullyConfig
} from '@scullyio/scully'; import { criticalCSS } from '@scullyio/scully-plugin-critical-css'; export const config: ScullyConfig = { defaultPostRenderers: [criticalCSS], };
@puku0x PWA化 • @angular/service-workerとの組み合わせに課題 ◦ https://github.com/scullyio/scully/issues/529 ◦ https://github.com/angular/angular/issues/16051 • Workbox等の利用を推奨
19
import { registerPlugin } from '@scullyio/scully'; export const customPlugin =
'customPlugin'; const plugin = async (html: string): Promise<string> => { // レンダリングする文字列(HTML)を返す return html; }; registerPlugin('render', customPlugin, plugin); カスタムプラグイン 20
const plugin = async (html: string): Promise<string> => { const
workboxScript = ` <script defer scullyKeep> (function() { if ('serviceWorker' in navigator) { window.addEventListener('load', function() { navigator.serviceWorker.register(service-worker.js'); }); } })(); </script>`; return html.replace(/<\/head/i, `${workboxScript}</head`); }; registerPlugin('render', workboxPlugin, plugin); 21
@puku0x 22 https://github.com/puku0x/puku0x.net
@puku0x 23
@puku0x Scullyの今後 • ドキュメント拡充 • プラグイン追加 ◦ https://github.com/scullyio/scully/tree/main/libs/plugins • Angular以外も対応予定?
24
@puku0x まとめ • Scullyを使うと簡単にSSGを導入できる ◦ 既存の資産が活かせる ◦ エコシステム拡充中 ◦ https://scully.io/
25
@puku0x 26 https://www.vega-c.com/recruit/
Thank you! @puku0x Noriyuki Shinpuku