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
Webpacker の webpack.config.js を見る…つもりだった話/Toyam...
Search
muryoimpl
December 08, 2018
Technology
810
0
Share
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
1.2k
人魚とたわむれる
muryoimpl
0
50
Kanzawa.rbのLT大会を支える技術の裏側を変更する Ruby on Rails + Litestream 編
muryoimpl
0
1.8k
Kanazawa.rb LT大会用/kzlt コマンドの説明 2024/01版
muryoimpl
0
3.1k
kzltコマンドの新たなソリューションについて
muryoimpl
0
3k
俺とTODOアプリ~Linearの変~
muryoimpl
0
2.7k
POSIX文字クラスでの躓き
muryoimpl
0
2.4k
/kzlt コマンドとは
muryoimpl
0
1k
meetup.kzrb.org の更新を考える 事前激闘編
muryoimpl
0
1.6k
Other Decks in Technology
See All in Technology
[最強DB講義]推薦システム | 基礎編
recsyslab
PRO
1
170
AIを共同作業者にして書籍を執筆する方法 / How to Write a Book with AI as a Co-Creator
ama_ch
2
130
[OpsJAWS 40]リリースしたら終わり、じゃなかった。セキュリティ空白期間をAWS Security Agentで埋める
sh_fk2
3
240
The Journey of Box Building
tagomoris
4
2.9k
Shipping AI Agents — Lessons from Production
vvatanabe
0
250
AI バイブコーティングでキーボード不要?!
samakada
0
580
「誰一人取り残されない」 AIエージェント時代のプロダクト設計思想 Product Management Summit 2026
mizushimac
1
210
国内外の生成AIセキュリティの最新動向 & AIガードレール製品「chakoshi」のご紹介 / Latest Trends in Generative AI Security (Domestic & International) & Introduction to AI Guardrail Product "chakoshi"
nttcom
3
1.2k
レビューしきれない?それは「全て人力でのレビュー」だからではないでしょうか
amixedcolor
0
330
AgentCore Managed Harness を使ってみよう
yakumo
2
110
QGISプラグイン CMChangeDetector
naokimuroki
1
410
Do Ruby::Box dream of Modular Monolith?
joker1007
1
350
Featured
See All Featured
So, you think you're a good person
axbom
PRO
2
2k
Embracing the Ebb and Flow
colly
88
5k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
170
Ethics towards AI in product and experience design
skipperchong
2
260
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
64
55k
The Limits of Empathy - UXLibs8
cassininazir
1
310
Tell your own story through comics
letsgokoyo
1
900
A better future with KSS
kneath
240
18k
How to build a perfect <img>
jonoalderson
1
5.4k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.1k
How to make the Groovebox
asonas
2
2.1k
The Art of Programming - Codeland 2020
erikaheidi
57
14k
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