split js with vendor/application

avoid one huge js bundle and instead break it down
to application and vendor (3rd party) our app changes
a lot, vendor changes a lot less
This commit is contained in:
Sam 2013-12-23 10:32:07 +11:00
parent f7827456af
commit b67a3a85dd
7 changed files with 57 additions and 68 deletions

View File

@ -1,34 +1,4 @@
// This is a manifest file that'll be compiled into including all the files listed below.
// Add new JavaScript code in separate files in this directory and they'll automatically
// be included in the compiled file accessible from http://example.com/assets/application.js
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
//= require ./env
// probe framework first
//= require ./discourse/lib/probes.js
// Externals we need to load first
<%
if Rails.env.development?
require_asset ("development/jquery-2.0.3.js")
else
require_asset ("production/jquery-2.0.3.min.js")
end
require_asset("message-bus")
require_asset ("jquery.ui.widget.js")
require_asset ("handlebars.js")
if Rails.env.development?
require_asset ("development/ember.js")
else
require_asset ("production/ember.js")
end
require_asset ("./main_include.js")
# Include plugin javascripts

View File

@ -0,0 +1,7 @@
<%
if Rails.env.development?
require_asset ("development/ember.js")
else
require_asset ("production/ember.js")
end
%>

View File

@ -0,0 +1,7 @@
<%
if Rails.env.development?
require_asset ("development/jquery-2.0.3.js")
else
require_asset ("production/jquery-2.0.3.min.js")
end
%>

View File

@ -1,39 +1,3 @@
//= require_tree ./discourse/ember
// The Vendored JS
//= require LAB.js
//= require Markdown.Converter.js
//= require Markdown.Editor.js
//= require better_markdown.js
//= require bootbox.js
//= require bootstrap-alert.js
//= require bootstrap-button.js
//= require bootstrap-dropdown.js
//= require bootstrap-modal.js
//= require bootstrap-transition.js
//= require chosen.jquery.js
//= require ember-renderspeed.js
//= require favcount.js
//= require handlebars.js
//= require jquery.ba-replacetext.js
//= require jquery.ba-resize.min.js
//= require jquery.color.js
//= require jquery.cookie.js
//= require jquery.fileupload.js
//= require jquery.iframe-transport.js
//= require jquery.putcursoratend.js
//= require jquery.tagsinput.js
//= require jquery.ui.widget.js
//= require jquery.sortable.js
//= require lodash.js
//= require md5.js
//= require modernizr.custom.00874.js
//= require mousetrap.js
//= require rsvp.js
//= require show-html.js
//= require lock-on.js
//= require ember-cloaking
//= require ./discourse/helpers/i18n_helpers
//= require ./discourse/mixins/ajax
//= require ./discourse

View File

@ -0,0 +1,41 @@
//= require ./env
//= require ./discourse/lib/probes.js
//= require handlebars.js
//= require jquery_include.js
//= require ember_include.js
//= require message-bus
//= require jquery.ui.widget.js
//= require_tree ./discourse/ember
//= require LAB.js
//= require Markdown.Converter.js
//= require Markdown.Editor.js
//= require better_markdown.js
//= require bootbox.js
//= require bootstrap-alert.js
//= require bootstrap-button.js
//= require bootstrap-dropdown.js
//= require bootstrap-modal.js
//= require bootstrap-transition.js
//= require chosen.jquery.js
//= require ember-renderspeed.js
//= require favcount.js
//= require jquery.ba-replacetext.js
//= require jquery.ba-resize.min.js
//= require jquery.color.js
//= require jquery.cookie.js
//= require jquery.fileupload.js
//= require jquery.iframe-transport.js
//= require jquery.putcursoratend.js
//= require jquery.tagsinput.js
//= require jquery.ui.widget.js
//= require jquery.sortable.js
//= require lodash.js
//= require md5.js
//= require modernizr.custom.00874.js
//= require mousetrap.js
//= require rsvp.js
//= require show-html.js
//= require lock-on.js
//= require ember-cloaking

View File

@ -13,8 +13,8 @@
<link rel="apple-touch-icon" type="image/png" href="<%=SiteSetting.apple_touch_icon_url%>">
<%= javascript_include_tag "preload_store" %>
<%= javascript_include_tag "locales/#{I18n.locale}" %>
<%= javascript_include_tag "vendor" %>
<%= javascript_include_tag "application" %>
<%- if staff? %>
<%= javascript_include_tag "admin"%>

View File

@ -58,7 +58,7 @@ module Discourse
path =~ /assets\/images/ && !%w(.js .css).include?(File.extname(filename))
end]
config.assets.precompile += ['common.css', 'desktop.css', 'mobile.css', 'admin.js', 'admin.css', 'shiny/shiny.css', 'preload_store.js', 'browser-update.js']
config.assets.precompile += ['vendor.js', 'common.css', 'desktop.css', 'mobile.css', 'admin.js', 'admin.css', 'shiny/shiny.css', 'preload_store.js', 'browser-update.js']
# Precompile all defer
Dir.glob("#{config.root}/app/assets/javascripts/defer/*.js").each do |file|