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
PuppeteerでいらないCSSを消す
Search
Hiroyuki ANAI
June 19, 2019
Programming
29k
23
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
PuppeteerでいらないCSSを消す
@pirosikick の発表資料です。
https://mentaico-js.connpass.com/event/132416/
Hiroyuki ANAI
June 19, 2019
More Decks by Hiroyuki ANAI
See All by Hiroyuki ANAI
安心して変更できるWebフロントエンドの作り方
pirosikick
7
3.3k
書き換えて学ぶTemporal #fukts
pirosikick
2
510
fukuoka.ts #3 社内でESLintの共通設定を配りたい2025年春版
pirosikick
3
510
compilerOptions、全部読んだ
pirosikick
1
320
Step Functionsの設計時に知っておいたほうがいいかもしれないこと
pirosikick
0
560
Go言語による並行処理「4.4 orチャネル」の図
pirosikick
0
510
サイボウズWebフロントエンド脱レガシーの今までとこれから
pirosikick
6
17k
@cybozu/eslint-configから学ぶ、全社共通ESLint configの運用
pirosikick
4
1.9k
Web Share Target API #w3fukuoka
pirosikick
0
750
Other Decks in Programming
See All in Programming
CodeRabbitの効果検証と過ごしてみた3ヶ月
armondando
0
210
Rでドレミ/Do-Re-Mi_with_R
florets1
0
130
Compiling a real-world CLI tool to native with Static Hermes
tmikov2023
0
100
Verilogで学ぶCPU自作入門
uyuki234
8
4.1k
コードレビューのボトルネックを"する側"と"される側"の両面から解消する
yub0n
2
1.5k
技術的負債の返済は、AI時代の複利で効く投資 — 経営としての意思決定とその遂行
curekoshimizu
1
2.3k
外から家のPCの電源入れたい!をPHPで解決する
kawashimo0
1
130
IBM Bob でAI駆動開発『QC-Playbook』
ichirokano2
0
110
Turning Architecture into Unit Tests in the AI Era (NSSpain XIV)
steliosf
PRO
1
140
R8 の設定見直しでアプリサイズ削減
andpad
0
190
Starting & Sustaining Code-Based E2E Testing for Non-Coding QA Teams( #jasstniigata )
teyamagu
PRO
1
960
Agentic Software Factoryに、すごく賢いIF文を。 / super smart IF statement into the Agentic Software Factory.
rkaga
8
2.1k
Featured
See All Featured
My Coaching Mixtape
mlcsv
0
350
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
480
Reality Check: Gamification 10 Years Later
codingconduct
0
2.3k
What's in a price? How to price your products and services
michaelherold
247
13k
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
580
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
Tell your own story through comics
letsgokoyo
1
1.1k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
4
1.2k
Design in an AI World
tapps
1
350
Facilitating Awesome Meetings
lara
57
7.2k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.8k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
530
Transcript
͍Βͳ͍$44Λ 1VQQFUFFSͰফ͢ !QJSPTJLJDL 8FC (PPHMF*0ͷ8FCΛ·ͱΊΔձ
ࣗݾհ w !QJSPTJLJDL w αΠϘζגࣜձࣾ ϑϩϯτΤϯυΤΩεύʔτνʔϜ w طʹ͝ଘͩͱࢥ͍·͕͢ɺ ࡢɺঁ͕࢈·Ε·ͨ͠!
࠷͍ۙͬͯΔࣄ w ڊେͳ$44ͷTUZMFEDPNQPOFOUTԽ w ສߦ͋Δ͕ɺશͯͷελΠϧ͕ඞཁͳΘ͚Ͱͳ͍ w ͦͷଞͷ w NJODTTͱ͍͏֦ுࢠͳͷʹѹॖ͞Ε͍ͯͳ͍ w
CPPUTUSBQGPOUBXFTPNFͷελΠϧΛ্ॻ͖͍ͯ͠Δ w ৄࡉ͕ߴ͗͢ΔελΠϧ͕݁ߏ͋ΔFUD
Ͳ͏ઓ͑Α͍ͷ͔ Θ͔ΒΜ
.PEFSO8FC5FTUJOHBOE"VUPNBUJPOXJUI1VQQFUFFS IUUQTXXXZPVUVCFDPNXBUDI W.CO"5-$V,* 1VQQFUFFSͰ +4ɾ$44ͷΧόϨοδ͕ औΕ·͢
͜ͷػೳΛ͑ ͬͯͳ͍ελΠϧΛ ୳͠ग़ͤΔͷͰʁ
1VQQFUFFSͰ $44ͷΧόϨοδΛऔಘ const puppeteer = require('puppeteer'); (async () => {
// ブラウザの起動 const browser = await puppeteer.launch(); const page = await browser.newPage(); // カバレッジの収集を開始 await page.coverage.startCSSCoverage(); // カバジッジを取りたいページを徘徊 await page.goto(…); … // カバレッジの収集を終了 const cssCoverage = await page.coverage.stopCSSCoverage(); … })();
QVQQFUFFSUPJTUBOCVMͰ OZD͕ॲཧՄೳͳϑΥʔϚοτʹม const pti = require('puppeteer-to-istanbul'); // .nyc_output/*を生成 pti.write(cssCoverage);
)5.-ܗࣜͷϨϙʔτΛੜ w OQYOZDSFQPSUSFQPSUFSIUNM w DPWFSBHFҎԼʹ)5.-Λग़ྗ w PQFODPWFSBHFJOEFYIUNM
εΫγϣషΔ
खಈͰফ͢ͷਏͦ͏ ΧόϨοδ͔ΒࣗಈͰ ফͤͳ͍͔ʁ
OZD@PVUQVUͷத w PVUKTPO w ֤ϑΝΠϧͷΧόϨοδใ w KT DTTKT w $44ϑΝΠϧͦͷͷ
w ֦ுࢠ͕KTʹͳ͍ͬͯΔͷṖ
OZD@PVUQVUPVUKTPOͷ TϑΟʔϧυ͕͑ͦ͏ // .nyc_output/out.jsonの構造 { "ファイルパス": { "path": "ファイルパス", "s":
{ "行数": 0 or 1 // 1の場合、カバレッジ有り … }, … }, … }
ෆཁͳߦΛফ͢ॲཧʢΠϝʔδʣ const fs = require('fs'); const readline = require('readline'); //
out.jsonのsフィールドから不要な行を消す処理のイメージ const removeUnusedLines = (filePath, s) => new Promise(resolve => { const reader = readline.createInterface({ input: fs.createReadStream(filePath) }); let currentLine = 0; const lines = []; // ファイルから1行ずつ読む reader.on('line', line => { // カバレッジがある行を残す if (s[currentLine++]) { lines.push(line); } }); reader.on('close', () => resolve(lines)); });
݁Ռ w ΧόϨοδ͕͔͠ͳ͔ͬͨ w ສߦˠߦ w ·ͩଟ͍͕ΪϦΪϦઓ͑Δߦʹͳͬͨ
ϋϚͬͨͱ͜Ζ
QBHFHPUPͷͨͼʹ ΧόϨοδ͕Ϧηοτ͞ΕΔ w ҎԼͷΑ͏ʹରॲ w HPUPຖʹΧόϨοδΛੜ w QUPJXSJUFҰͭͷΧόϨοδ͔͠ड͚͚ͳ͍ͷͰ w ෳͷΧόϨοδΛϚʔδͯ͠
ҰͭͷΧόϨοδΛੜ
QVQQFUFFS͕ग़ྗ͢Δ ΧόϨοδͷߏ [ { url: "ファイルのURL", text: "ファイルの中身", ranges: [
// カバレッジの開始位置・終了位置の配列 { start: 0, end: 100 }, … ] }, … ]
ෳͷΧόϨοδΛϚʔδ { url: "ファイルA", text: "…", ranges: [ { start:
0, end: 100 }, { start: 201, end: 300 } ] } { url: "ファイルA", text: "…", ranges: [ { start: 101, end: 200 }, { start: 250, end: 350 } ] } ΧόϨοδͦͷ ΧόϨοδͦͷ { url: "ファイルA", text: "…", ranges: [ { start: 0, end: 100 }, { start: 101, end: 200 }, { start: 201, end: 350 } ] }
ΧόϨοδ͕ൃੜ͠ͳ͍ w !NFEJBએݴɺ!GPOUGBDFએݴʹ ΧόϨοδ͕ൃੜ͠ͳ͍ w *TTVFʹొ͞Ε͍͕ͯͨόά͔༷͔͔Βͳ͍ w ҎԼͷΑ͏ʹରॲ w !GPOUGBDFએݴΧόϨοδ͋Γͳؔ͠ΘΒͣ͢
w !NFEJBએݴͷελΠϧʹΧόϨοδ͕͋Δ߹ ͢
͓ΘΓ w 1VQQFUFFS&&ςετҎ֎ͷ͍ํͰ͖Δʂ w ࠷ऴతʹεΫγϣΛऔ͓͍ͬͯͯ ը૾ࠩΛग़ͤΔΑ͏ʹͯ͠ΑΓ࣮֬ʹෆཁͳελΠϧΛ ফͤΔΑ͏ʹͨ͠
͋Γ͕ͱ͏ ͍͟͝·ͨ͠