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
Webpacker の webpack.config.js を見る…つもりだった話/Toyam...
Search
muryoimpl
December 08, 2018
Technology
890
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Webpacker の webpack.config.js を見る…つもりだった話/Toyamarb#35LightningTalk_WebpackerConfigShower
Toyama.rb#35 年末LT大会 でしたLTスライド。
Webpacker 内部にある webpack.config.js を出力したかったが、見え過ぎちゃって困った話。
muryoimpl
December 08, 2018
More Decks by muryoimpl
See All by muryoimpl
Rubyで鍛える仕組み化プロヂュース力
muryoimpl
0
2.4k
人魚とたわむれる
muryoimpl
0
69
Kanzawa.rbのLT大会を支える技術の裏側を変更する Ruby on Rails + Litestream 編
muryoimpl
0
2.3k
Kanazawa.rb LT大会用/kzlt コマンドの説明 2024/01版
muryoimpl
0
3.1k
kzltコマンドの新たなソリューションについて
muryoimpl
0
3.1k
俺とTODOアプリ~Linearの変~
muryoimpl
0
2.9k
POSIX文字クラスでの躓き
muryoimpl
0
2.4k
/kzlt コマンドとは
muryoimpl
0
1.1k
meetup.kzrb.org の更新を考える 事前激闘編
muryoimpl
0
1.7k
Other Decks in Technology
See All in Technology
人間はどの意思決定を手放せるのか
kawasima
16
8.2k
AIに任せた品質は、誰が見立てるのか - AI時代のテストマネジメント
nakanao
3
3k
AIエージェントを最高のパートナーに育てる方法|評価と判断軸を育てる5つのステップ
koichiaoki
1
160
SREへの勘違いに気づいた後の話
tomodakengo
0
150
Oracle Cloud Infrastructure(OCI):Onboarding Session(はじめてのOCI/Oracle Supportご利⽤ガイド)
oracle4engineer
PRO
2
20k
ほんとうの信頼性はヒーローが死んでからはじまる / True reliability begins after the hero dies
vtryo
0
120
Genieを崇めよ
kameitomohiro
0
170
The Knowledge Spine: A Machine-Executable Ontology for Governed Marketing Activation
vananth22
0
130
C#コードの結合を可視化する Roslyn解析による設計改善と リファクタリング判断
dora56
0
610
作って終わりじゃないサーバーレス 〜9年運用する大規模EC物流API基盤の設計・運用のリアル〜
zozotech
PRO
0
520
【技術的負債conf】事業成長に伴う技術的負債の説明責任とAIによるモニタリング、認知的負債について
i35_267
4
2.1k
時うどん〜Socket.getifaddrsで学ぶネットワーク編 / Tokiudon: The Socket.getifaddrs Edition
coe401_
4
260
Featured
See All Featured
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
340
VelocityConf: Rendering Performance Case Studies
addyosmani
331
25k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
680
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.2k
How to train your dragon (web standard)
notwaldorf
97
6.8k
Tell your own story through comics
letsgokoyo
1
1.1k
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
770
Making the Leap to Tech Lead
cromwellryan
135
10k
Ethics towards AI in product and experience design
skipperchong
2
380
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
550
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.2k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
710
Transcript
Webpacker の Webpacker の webpack.config.js を見る… webpack.config.js を見る… つもりだった話 2018-12-08
Toyama.rb #35 年末LT 大会 @muryoimpl
名前: 無量井 健( むりょうい けん) @kunitoo の同僚で、金沢でフルリモート勤務中 Toyama.rb は 2
回目の参加 です 最近は *.rb というより、*.js を書くことが多い 自己紹介 自己紹介
Webpacker の Webpacker の webpack.config.js を見る… webpack.config.js を見る… つもりだった話
None
Ruby on Rails に組み込める gem sprockets と連携しつつ、webpack を使うことができる Rails とともにモダンな
JavaScript libraries/framework を使 って開発ができるようになる Webpacker とは Webpacker とは
Ruby on Rails が提供してくれているいい感じのデフォルト値 がどんなものなのかわかりにくい 内部で npm package を経由しているので Ruby
だけ見てもわ からない プログラマブルな書かれ方をしているので、脳内で組み立てな いと全体がわかりにくい Webpacker の気になるところ Webpacker の気になるところ
なので、 なので、 さくっと見れるものが さくっと見れるものが 欲しくなるじゃないですか 欲しくなるじゃないですか
なので、やってみた なので、やってみた
webpacker_config_shower webpacker_config_shower という gem を作りました という gem を作りました https://rubygems.org/gems/webpacker_config_shower https://rubygems.org/gems/webpacker_config_shower
結論 結論
見えすぎて困った 見えすぎて困った
$ bin/rails webpacker:config:show { "output": { ... "publicPath": "/packs/", "pathinfo":
true }, "resolve": { "extensions": [ ... ] }, ... "entry": { ... }, ... "plugins": [ { "keys": [ "GREP_COLOR", "CLOUDSDK_PYTHON", "ZPLUG_CACHE_DIR", ... "BUNDLER_ORIG_BUNDLE_BIN_PATH", "BUNDLER_ORIG_RB_USER_INSTALL",
webpack の plugin 部分などのオブジェクトが記載されている 箇所が 展開されて 表示されてしまう… 設定がclass として表現されているから?そのまま表示は厳し い?
これはおとなしくwebpacker のpackage/environments を 見るしかないのか… おわかりだろうか… おわかりだろうか…
https://github.com/muryoimpl/webpacker_config_shower rails plugin new webpacker_config_shower railtie を Rails::Engine を継承したものに変更(Rake ファイル
ロードのため) webapcker で内部コマンドを実行する Runner を継承して node コマンドを実行する Gem としてやったこと Gem としてやったこと
require 'webpacker' require 'webpacker/runner' require 'open3' module WebpackerConfigShower class Runner
< ::Webpacker::Runner def self.run(argv) ENV["NODE_ENV"] ||= Rails.env super end def run cmd = [ "node", "-e", *[ "const conf = require('#{@webpack_config}')", "const { format } = require('util')", "console.log(format('%j', conf))", ].join(';') ] Dir.chdir(@app_path) do _, stdout, _ = *Open3.popen3(*cmd) puts JSON.pretty_generate(JSON.parse(stdout.read)) end end