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
Rails with Webpack
Search
sporto
January 28, 2015
Technology
1
230
Rails with Webpack
Using Webpack to build a JavaScript heavy application with Rails
sporto
January 28, 2015
Tweet
Share
More Decks by sporto
See All by sporto
React inside Elm
sporto
2
180
Elm
sporto
1
260
Redux: Flux Reduced
sporto
1
360
Practically Immutable
sporto
0
200
Webpack and React
sporto
4
390
Lesson learnt building Single Page Application
sporto
0
130
Grunt
sporto
1
190
Safe Testing in Ruby
sporto
1
130
Go - A great language for building web applications
sporto
1
340
Other Decks in Technology
See All in Technology
SREのプラクティスを用いた3領域同時 マネジメントへの挑戦 〜SRE・情シス・セキュリティを統合した チーム運営術〜
coconala_engineer
2
650
usermode linux without MMU - fosdem2026 kernel devroom
thehajime
0
230
こんなところでも(地味に)活躍するImage Modeさんを知ってるかい?- Image Mode for OpenShift -
tsukaman
0
140
AWS Network Firewall Proxyを触ってみた
nagisa53
1
230
制約が導く迷わない設計 〜 信頼性と運用性を両立するマイナンバー管理システムの実践 〜
bwkw
3
930
Context Engineeringが企業で不可欠になる理由
hirosatogamo
PRO
3
580
~Everything as Codeを諦めない~ 後からCDK
mu7889yoon
3
370
20260204_Midosuji_Tech
takuyay0ne
1
150
仕様書駆動AI開発の実践: Issue→Skill→PRテンプレで 再現性を作る
knishioka
2
650
We Built for Predictability; The Workloads Didn’t Care
stahnma
0
140
OWASP Top 10:2025 リリースと 少しの日本語化にまつわる裏話
okdt
PRO
3
760
Ruby版 JSXのRuxが気になる
sansantech
PRO
0
150
Featured
See All Featured
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3k
Into the Great Unknown - MozCon
thekraken
40
2.3k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
[SF Ruby Conf 2025] Rails X
palkan
1
750
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.7k
How to Talk to Developers About Accessibility
jct
2
130
Prompt Engineering for Job Search
mfonobong
0
160
Mind Mapping
helmedeiros
PRO
0
81
The Curse of the Amulet
leimatthew05
1
8.5k
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
61
52k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.1k
Git: the NoSQL Database
bkeepers
PRO
432
66k
Transcript
Rails with Webpack Sebastian Porto 1 / 31
The Assests Pipeline It is great for most Rails apps
2 / 31
The Assests Pipeline But not great for JS heavy apps
3 / 31
JS heavy applications Lots of JavaScript Multiple entry points Only
include code we need on each point Complex dependecy tree 4 / 31
Dependency tree 5 / 31
Resolving a dependency complex tree Possible with the Assets Pipeline
but ugly 6 / 31
Dependency tree: Sprockets In Sprockets manifest: / / = r
e q u i r e o r d e r s / / = r e q u i r e u s e r s 7 / 31
Dependency tree: Sprockets The in JS: Globals / / =
r e q u i r e l o a d e r A p p . O r d e r s = f u n c t i o n ( ) { . . . } Or AMD / / = r e q u i r e l o a d e r r e q u i r e ( [ ' l o a d e r ' ] , f u n c t i o n ( l o a d e r ) { . . . } ) 8 / 31
Dependency tree: Sprockets / / = r e q u
i r e l o a d e r r e q u i r e ( [ ' l o a d e r ' ] , f u n c t i o n ( l o a d e r ) { . . . } ) This is redundant coding == Hard to mantain 9 / 31
Wouldn’t it be nice to avoid this repetition? 10 /
31
What is Webpack? JavaScript module bundler 11 / 31
Webpack Bundle AMD, CommonJS, ES6 modules Resolves dependecies Create multiple
bundles Loads about anything (CSS, images, fonts, …) 12 / 31
Webpack with Rails 13 / 31
Install Webpack with NPM n p m i n s
t a l l w e b p a c k - g 14 / 31
Config file Specifies: entry points and output files loaders to
use (e.g SASS, JSX, etc) 15 / 31
Write your code Using AMD, CommonJS or ES6 v a
r O r d e r s = r e q u i r e ( ' o r d e r s ' ) O r d e r s . d o S o m e t h i n g ( . . . ) 16 / 31
Watch w e b p a c k - -
w a t c h 17 / 31
Add the bundles to the Rails assets 18 / 31
Require the bundles from Sprockets In orders.js / / =
r e q u i r e c o m m o n - b u n d l e / / = r e q u i r e o r d e r s - b u n d l e 19 / 31
The Assets pipeline will fingerprint the JS in production But
we get the benefits of using Webpack: Modular code Multiple bundles 20 / 31
Other benefits 21 / 31
Code is portable e.g. if we ever need to move
our front-end to something else than Rails 22 / 31
Modularise all the things JS Images CSS / LESS /
SASS Fonts 23 / 31
Better encapsulation of JS No Globals 24 / 31
Use NPM to manage FE dependencies With package.json If that
appeals to you 25 / 31
Leverage the NPM echo system Easily load and use packages
from there 26 / 31
Testing is way better With Rails you need to load
the whole Env Gems like Konacha and Teaspoon help Slow 27 / 31
Testing is way better With Webpack you can use anything
you want Jest, Buster, Karma, … Faster 28 / 31
Browserify? Mostly does the same Webpack = batteries included Browserify
= Everything in plugins! 29 / 31
Thanks @sebasporto 30 / 31
31 / 31