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.5k
人魚とたわむれる
muryoimpl
0
71
Kanzawa.rbのLT大会を支える技術の裏側を変更する Ruby on Rails + Litestream 編
muryoimpl
0
2.4k
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
React Nativeでの OTA Updateって、 どう説明する?
ichiki1023
0
140
並行性の問題を防げ!実践トランザクション入門
occhi
0
250
The kernel report
ennael
PRO
1
240
大阪オフィスに Unitree Go2 がやってきたので Physical AI やってみた
dafujii
0
290
BedrockとLambdaで作る リアルタイム進行型推理ゲーム
kawametho
0
180
Claude起点の仕様駆動開発
tanakaseiya
0
360
[2026 Oracle Technical Deep Dive] オンプレミスDBのCloud移行アプローチ:移行計画に基づくメソッドとツールの選択 (2026年9月17日開催)
oracle4engineer
PRO
0
130
OpenSharing について熱く語る〜AI アセットの共有について〜
kameitomohiro
0
210
OSC2026on_the-world-is-waiting-for-your-voice.pdf
naruoga
0
340
サーバーフルコンピューティング?AWS Lambda
iwatatomoya
1
240
AIアプリを使い分けるための共通ツール基盤を考えてみる#devio2026
osawa
0
220
生成AIを使って「人が」考える技術 ― AI時代の人機共想と実践ノウハウ|UNITT AC2026
ishiirikie
0
540
Featured
See All Featured
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
310
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
68
58k
Believing is Seeing
oripsolob
1
240
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
What's in a price? How to price your products and services
michaelherold
247
13k
Bootstrapping a Software Product
garrettdimon
PRO
306
120k
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.4k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.6k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
600
The #1 spot is gone: here's how to win anyway
tamaranovitovic
4
1.2k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
18k
Embracing the Ebb and Flow
colly
88
5.2k
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