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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
puku0x
October 17, 2020
Technology
390
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
1
590
新メンバーのために、シニアエンジニアが環境を作る時代
puku0x
0
1.6k
Agent Skills 入門
puku0x
0
2k
ファインディにおけるフロントエンド技術選定の歴史
puku0x
2
2.2k
生成AIではじめるテスト駆動開発
puku0x
0
1.5k
実践!カスタムインストラクション&スラッシュコマンド
puku0x
2
3.4k
Nx × AI によるモノレポ活用 〜コードジェネレーター編〜
puku0x
0
1.7k
ファインディにおけるフロントエンド技術選定の歴史
puku0x
2
320
ファインディでのGitHub Actions活用事例
puku0x
9
3.9k
Other Decks in Technology
See All in Technology
Flutterをカメラで動かしたかった話
sony
1
140
関東Kaggler会発表資料
takoi
1
230
20260807_第6回_関東kaggler会LT_claw系bot xangiと始める、"寂しくない" kaggle
sugupoko
0
280
Breaking the Seal: Static Deobfuscation of Compiled V8 JavaScript Bytecode Malware
hshrzd
0
790
【AG-UI × A2UI × MCP Apps】Generative UIをやさしく解説する
nrinetcom
PRO
1
120
Head First モブプログラミング / Head First Mobprogramming
takaking22
10
12k
ラジオの科学
frievea
0
320
制約理論(ToC)入門 2026版
recruitengineers
PRO
8
2.3k
ボトムアップ文化が強い組織で セキュリティをどう根付かせていくかの現在進行形の話 / Making Security Stick in a Bottom-Up Organization
yamaguchitk333
0
220
Master Dataグループ紹介資料
sansan33
PRO
1
4.8k
My broken English still works: speaking at global OSS events
naruoga
0
100
Model Studio CLI × Token Plan
maigo999
0
180
Featured
See All Featured
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
Building AI with AI
inesmontani
PRO
1
1.1k
Raft: Consensus for Rubyists
vanstee
141
7.6k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.1k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
240
From π to Pie charts
rasagy
0
280
Chasing Engaging Ingredients in Design
codingconduct
0
270
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
KATA
mclloyd
PRO
35
15k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
450
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
3k
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