mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-30 10:58:31 -05:00
sprockets upgrade
stop bundling all js files in dev, replace with turbo boosted serving of assets
This commit is contained in:
parent
474080a414
commit
8367951000
4 changed files with 46 additions and 9 deletions
5
Gemfile
5
Gemfile
|
@ -108,6 +108,11 @@ group :development do
|
||||||
gem 'pry-rails'
|
gem 'pry-rails'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# we are using a custom sprockets repo to work around: https://github.com/rails/rails/issues/8099#issuecomment-16137638
|
||||||
|
# REVIEW EVERY RELEASE
|
||||||
|
gem "sprockets", :git => "git://github.com/SamSaffron/sprockets.git", :branch => "rails-compat"
|
||||||
|
|
||||||
|
|
||||||
# this is an optional gem, it provides a high performance replacement
|
# this is an optional gem, it provides a high performance replacement
|
||||||
# to String#blank? a method that is called quite frequently in current
|
# to String#blank? a method that is called quite frequently in current
|
||||||
# ActiveRecord, this may change in the future
|
# ActiveRecord, this may change in the future
|
||||||
|
|
19
Gemfile.lock
19
Gemfile.lock
|
@ -1,3 +1,14 @@
|
||||||
|
GIT
|
||||||
|
remote: git://github.com/SamSaffron/sprockets.git
|
||||||
|
revision: bacf2ec4d4d10cd8d1ab25a6360740314c512237
|
||||||
|
branch: rails-compat
|
||||||
|
specs:
|
||||||
|
sprockets (2.2.3)
|
||||||
|
hike (~> 1.2)
|
||||||
|
multi_json (~> 1.0)
|
||||||
|
rack (~> 1.0)
|
||||||
|
tilt (~> 1.1, != 1.3.0)
|
||||||
|
|
||||||
GIT
|
GIT
|
||||||
remote: git://github.com/callahad/omniauth-browserid.git
|
remote: git://github.com/callahad/omniauth-browserid.git
|
||||||
revision: af62d667626c1622de6fe13b60849c3640765ab1
|
revision: af62d667626c1622de6fe13b60849c3640765ab1
|
||||||
|
@ -209,7 +220,7 @@ GEM
|
||||||
has_ip_address (0.0.1)
|
has_ip_address (0.0.1)
|
||||||
hashie (1.2.0)
|
hashie (1.2.0)
|
||||||
highline (1.6.15)
|
highline (1.6.15)
|
||||||
hike (1.2.1)
|
hike (1.2.2)
|
||||||
hiredis (0.4.5)
|
hiredis (0.4.5)
|
||||||
httpauth (0.2.0)
|
httpauth (0.2.0)
|
||||||
i18n (0.6.4)
|
i18n (0.6.4)
|
||||||
|
@ -434,11 +445,6 @@ GEM
|
||||||
tilt (~> 1.3.3)
|
tilt (~> 1.3.3)
|
||||||
slop (3.4.3)
|
slop (3.4.3)
|
||||||
spork (0.9.2)
|
spork (0.9.2)
|
||||||
sprockets (2.2.2)
|
|
||||||
hike (~> 1.2)
|
|
||||||
multi_json (~> 1.0)
|
|
||||||
rack (~> 1.0)
|
|
||||||
tilt (~> 1.1, != 1.3.0)
|
|
||||||
systemu (2.5.2)
|
systemu (2.5.2)
|
||||||
temple (0.5.5)
|
temple (0.5.5)
|
||||||
terminal-notifier-guard (1.5.3)
|
terminal-notifier-guard (1.5.3)
|
||||||
|
@ -543,6 +549,7 @@ DEPENDENCIES
|
||||||
simplecov
|
simplecov
|
||||||
sinatra
|
sinatra
|
||||||
slim
|
slim
|
||||||
|
sprockets!
|
||||||
terminal-notifier-guard
|
terminal-notifier-guard
|
||||||
therubyracer
|
therubyracer
|
||||||
thin
|
thin
|
||||||
|
|
|
@ -22,9 +22,10 @@ Discourse::Application.configure do
|
||||||
# Do not compress assets
|
# Do not compress assets
|
||||||
config.assets.compress = false
|
config.assets.compress = false
|
||||||
|
|
||||||
# Concatenate all assets, even in development mode. This appears to be considerably
|
# Don't Digest assets, makes debugging uglier
|
||||||
# faster for reloading in development mode.
|
config.assets.digest = false
|
||||||
config.assets.debug = ENV['DEBUG_ASSETS'] == "1"
|
|
||||||
|
config.assets.debug = true
|
||||||
|
|
||||||
config.watchable_dirs['lib'] = [:rb]
|
config.watchable_dirs['lib'] = [:rb]
|
||||||
|
|
||||||
|
@ -39,5 +40,8 @@ Discourse::Application.configure do
|
||||||
BetterErrors::Middleware.allow_ip! ENV['TRUSTED_IP'] if ENV['TRUSTED_IP']
|
BetterErrors::Middleware.allow_ip! ENV['TRUSTED_IP'] if ENV['TRUSTED_IP']
|
||||||
|
|
||||||
config.enable_mini_profiler = true
|
config.enable_mini_profiler = true
|
||||||
|
|
||||||
|
require 'middleware/turbo_dev'
|
||||||
|
config.middleware.insert 0, Middleware::TurboDev
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
21
lib/middleware/turbo_dev.rb
Normal file
21
lib/middleware/turbo_dev.rb
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
module Middleware
|
||||||
|
# this class cheats and bypasses rails altogether if the client attme
|
||||||
|
class TurboDev
|
||||||
|
def initialize(app, settings={})
|
||||||
|
@app = app
|
||||||
|
end
|
||||||
|
def call(env)
|
||||||
|
# hack to bypass all middleware if serving assets, a lot faster 4.5 seconds -> 1.5 seconds
|
||||||
|
if (etag = env['HTTP_IF_NONE_MATCH']) && env['REQUEST_PATH'] =~ /^\/assets\//
|
||||||
|
name = $'
|
||||||
|
etag = etag.gsub "\"", ""
|
||||||
|
asset = Rails.application.assets.find_asset(name)
|
||||||
|
if asset && asset.digest == etag
|
||||||
|
return [304,{},[]]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
@app.call(env)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue