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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
sporto
January 28, 2015
Technology
240
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Rails with Webpack
Using Webpack to build a JavaScript heavy application with Rails
sporto
January 28, 2015
More Decks by sporto
See All by sporto
React inside Elm
sporto
2
200
Elm
sporto
1
290
Redux: Flux Reduced
sporto
1
380
Practically Immutable
sporto
0
210
Webpack and React
sporto
4
410
Lesson learnt building Single Page Application
sporto
0
150
Grunt
sporto
1
210
Safe Testing in Ruby
sporto
1
150
Go - A great language for building web applications
sporto
1
360
Other Decks in Technology
See All in Technology
AI時代の強いチームの作り方
yuukiyo
25
16k
『三匹の子ぶた』から学ぶネットワークセキュリティの昔と今 / Network Security: Then and Now Through the Lens of The Three Little Pigs
nttcom
1
1.7k
老害フォレンジッカーはAI羊の夢を見るか?
tadmaddad
0
210
名古屋の市バスGTFS-JPデータ×スガキヤ 最寄りバス停検索をAmazon ElastiCache Serverless for Valkeyで最適化する
usanchuu
1
370
Cursor Meetup Sapporo - Cursor物語 続編
cocacola917
0
130
20260608_Codexの可能性_ノンプログラマー向け_大城追記
doradora09
PRO
0
770
サイバー捜査員研修(後半)
nomizone
1
770
Eight Engineering Unit 紹介資料
sansan33
PRO
3
8.1k
NetBoxを利用した作業効率化の試み_NetDevNight4
tnoha
0
470
FORENSIA: ローカルLLMフォレンジックハーネス
sumeshi
2
230
グローバル基準のSREは、運用現場でどう機能したか:成熟度アセスメントの実践 / SRE NEXT 2026
sorawatanabe
0
110
Agent 時代の Kaggle 展望 / kaggle-in-the-agentic-era
upura
1
590
Featured
See All Featured
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
460
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.3k
Embracing the Ebb and Flow
colly
88
5.1k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
240
VelocityConf: Rendering Performance Case Studies
addyosmani
333
25k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
119
120k
Java REST API Framework Comparison - PWX 2021
mraible
34
9.6k
Utilizing Notion as your number one productivity tool
mfonobong
4
510
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
The Pragmatic Product Professional
lauravandoore
37
7.4k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.4k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
350
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