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 Assets LRUG
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Tymon Tobolski
December 09, 2013
Programming
7.6k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Rails Assets LRUG
Talk about
http://rails-assets.org
that I gave on London Ruby User Group
Tymon Tobolski
December 09, 2013
More Decks by Tymon Tobolski
See All by Tymon Tobolski
Only possible with Elixir - ubots Case Study
teamon
0
300
Fun with Elixir Macros
teamon
1
590
Elixir GenStage & Flow
teamon
2
1.1k
Elixir - Bydgoszcz Web Development Meetup
teamon
2
990
Sidekiq
teamon
1
200
Git - Monterail style
teamon
1
210
Rails Assets wroc_love.rb
teamon
1
800
Angular replacements for jQuery-based libraries
teamon
1
420
Angular replacements for jQuery-based libraries
teamon
2
340
Other Decks in Programming
See All in Programming
AIだと陥りがちなJakarta EE最新技術への移行時の落とし穴と解決策
tnagao7
0
110
代数的データ型って何が嬉しいの? #frontend_phpcon_do
kajitack
8
3.7k
生成AI時代にこそ効くGo | Why Go Works in the Age of Generative AI
mom0tomo
8
3.3k
LLMによるContent Moderationの本番運用の裏側と品質担保への挑戦
suikabar
3
710
Snowflake Summitでの新機能 CoCo / CoWork / snowflake-summit-2026-overall-what-new-coco
tatsuhiro
1
150
ローカルLLMを使ってB2Bサービスを作っていての学び
yaotti
0
200
Inside Stream API
skrb
1
740
依存関係から依存物へ―Dependencyという言葉の歴史をひも解く
j_lee
0
120
RTSPクライアントを自作してみた話
simotin13
0
610
技術的負債解消で開発者の未来を開く- AIの力でコード刷新
kmd2kmd
0
110
OSもどきOS
arkw
0
570
ECSアプリログをFireLensでコスト削減しようとしたけど諦めた話 in Fargate×Node.js
akihisaikeda
2
4.2k
Featured
See All Featured
Music & Morning Musume
bryan
47
7.2k
A Tale of Four Properties
chriscoyier
163
24k
The Invisible Side of Design
smashingmag
302
52k
Producing Creativity
orderedlist
PRO
348
40k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
5.9k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
How to Think Like a Performance Engineer
csswizardry
28
2.7k
The Cult of Friendly URLs
andyhume
79
6.9k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
52k
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
KATA
mclloyd
PRO
35
15k
Transcript
Rails Assets The solution to assets management in Rails London,
9.12.2013
Tymon Tobolski About me @iteamon github.com/teamon DRUG
March 14-16th 2014 Wrocław Poland wrocloverb.com
What is the problem? • Managing assets in rails app
is hard • Tons of incompatible javascript libraries • Unmaintainable legacy projects
Existing solutions • vendor/assets • bower • component • browserify
(npm) • asset gems
None
None
source 'https://rubygems.org' +source 'https://rails-assets.org' ! gem 'rails' ! group :assets
do gem 'sass-rails' gem 'uglifier' gem 'coffee-rails' + gem 'rails-assets-bootstrap' + gem 'rails-assets-angular' + gem 'rails-assets-leaflet' end
bundle install
application.js ! ! ! //= require_self +//= require bootstrap +//=
require angular +//= require leaflet //= require_tree . application.css ! ! /* *= require_self +*= require bootstrap +*= require leaflet *= require_tree . */
None
None
Pros • No more vendor/assets • Proper versioning • Dependency
resolution • No additional build step • Already used in few production apps with no big issues
How it works?
Bower registry name => git repository + meta
bower.json { "name": "bootstrap", "version": "3.0.3", "main": [ "./dist/js/bootstrap.js", "./dist/css/bootstrap.css"
], "dependencies": { "jquery": ">= 1.9.0" } }
Gem name { "name": "bootstrap", "version": "3.0.3", "main": [ "./dist/js/bootstrap.js",
"./dist/css/bootstrap.css" ], "dependencies": { "jquery": ">= 1.9.0" } }
Gem name bootstrap => rails-assets-bootstrap
Version { "name": "bootstrap", "version": "3.0.3", "main": [ "./dist/js/bootstrap.js", "./dist/css/bootstrap.css"
], "dependencies": { "jquery": ">= 1.9.0" } }
Version module RailsAssetsBootstrap VERSION = "3.0.3" end
Manifests { "name": "bootstrap", "version": "3.0.3", "main": [ "./dist/js/bootstrap.js", "./dist/css/bootstrap.css"
], "dependencies": { "jquery": ">= 1.9.0" } }
Manifest - sprockets # application.js //= require bootstrap Simple component
vendor/assets/javascripts/ - bootstrap.js - bootstrap/bootstrap.js
Manifest - sprockets # application.js //= require moment //= require
moment/lang/pl More complex component vendor/assets/javascripts/ - moment.js - moment/moment.js - moment/lang/en.js - moment/lang/pl.js
Dependencies { "name": "bootstrap", "version": "3.0.3", "main": [ "./dist/js/bootstrap.js", "./dist/css/bootstrap.css"
], "dependencies": { "jquery": ">= 1.9.0" } }
gemspec lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'rails-assets-bootstrap/version'
! Gem::Specification.new do |spec| spec.name = "rails-assets-bootstrap" spec.version = RailsAssetsBootstrap::VERSION # ... spec.add_dependency "rails-assets-jquery", ">= 1.9.0" # ... end
Rails Engine require "rails-assets-bootstrap/version" ! require "rails-assets-jquery" ! if defined?(Rails)
module RailsAssetsBootstrap class Engine < ::Rails::Engine # Rails -> use vendor directory. end end end
"## lib $ "## rails-assets-bootstrap $ $ &## version.rb $
&## rails-assets-bootstrap.rb "## vendor $ &## assets $ "## images $ $ &## bootstrap $ $ &## assets $ $ &## ico $ $ "## apple-touch-icon-114-precomposed.png $ $ "## apple-touch-icon-144-precomposed.png $ $ "## apple-touch-icon-57-precomposed.png $ $ "## apple-touch-icon-72-precomposed.png $ $ &## favicon.png $ "## javascripts $ $ "## bootstrap $ $ $ &## bootstrap.js $ $ &## bootstrap.js $ &## stylesheets $ "## bootstrap $ $ "## bootstrap-theme.scss $ $ &## bootstrap.scss $ &## bootstrap.scss "## Gemfile "## README.md "## Rakefile &## rails-assets-bootstrap.gemspec
Challenges
bower is a mess • just git clone • duplicates,
momentjs vs moment, swipe vs Swipe • separate repositories, e.g angular-bower • {bower, package, component}.json - unreliable • bower info missing ”main”
bower is a mess • no common structure • lib.js
at top level • src, dist, release, etc. directories • .{js,css}.min duplicates • not compiled packages • missing dependencies
Other issues • version spec differences • bundler API -
no versions in dependencies API request • web frontend is essential • rails-assets-jquery vs jquery-rails conflicts
Technical issues • Gem::Indexer bug • global bower cache -
custom bower fork • auto updates via bower api • index locking • background jobs, blocking • weak performance • do as much as possible in memory
We need your help • Spread the word • Improve
bower.json files • Bug discovering and fixing
None
Questions?