-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
split up base JS into vendor/app #860
Conversation
return (window.location.href.indexOf('debug=true') >= 0); | ||
} | ||
}; | ||
pageflow.log("Rails Asset Pipeline: <pageflow/base> is deprecated and will be removed from Pageflow. Use separate vendor and app assets."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long.
//= require_tree ./widgets | ||
//= require ./react | ||
|
||
pageflow = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Read only.
The way HTTP/2 streams all assets together makes the enormous asset bundles obsolete IMO. |
1 similar comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. Still, since Pageflow renders the script tags itself, I'd suggest inserting a script tag for pageflow/vendor.js
there. We can then remove vendor related stuff from pageflow/base.js
but keep everything else as is. That way pageflow/applications.js
files in host apps do not have to change at all. Only the //= require pageflow/base
directive will pull in a lot less stuff.
lib/pageflow/engine.rb
Outdated
@@ -88,5 +88,9 @@ class Engine < ::Rails::Engine | |||
FactoryGirl.definition_file_paths.unshift(Engine.root.join('spec', 'factories')) | |||
end | |||
end | |||
|
|||
initializer "pageflow.assets.precompile" do |app| | |||
app.config.assets.precompile += %w( vendor.js app.js ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not use spaces inside percent literal delimiters.
lib/pageflow/engine.rb
Outdated
@@ -88,5 +88,9 @@ class Engine < ::Rails::Engine | |||
FactoryGirl.definition_file_paths.unshift(Engine.root.join('spec', 'factories')) | |||
end | |||
end | |||
|
|||
initializer "pageflow.assets.precompile" do |app| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer single-quoted strings when you don't need string interpolation or special symbols.
lib/pageflow/engine.rb
Outdated
end | ||
end | ||
|
||
app.config.assets.precompile << lambda do |path, filename| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent indentation detected.
lib/pageflow/engine.rb
Outdated
pageflow/vendor.js | ||
video-js.swf vjs.eot vjs.svg vjs.ttf vjs.woff) | ||
|
||
app.config.assets.precompile << lambda do |path, _filename| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent indentation detected.
lib/pageflow/engine.rb
Outdated
pageflow/print_view.css | ||
pageflow/lt_ie9.js pageflow/lt_ie9.css pageflow/ie9.js pageflow/ie9.css | ||
pageflow/vendor.js | ||
video-js.swf vjs.eot vjs.svg vjs.ttf vjs.woff) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Align the elements of an array literal if they span more than one line.
lib/pageflow/engine.rb
Outdated
pageflow/application_with_simulated_media_queries.css | ||
pageflow/print_view.css | ||
pageflow/lt_ie9.js pageflow/lt_ie9.css pageflow/ie9.js pageflow/ie9.css | ||
pageflow/vendor.js |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Align the elements of an array literal if they span more than one line.
lib/pageflow/engine.rb
Outdated
app.config.assets.precompile += %w(pageflow/editor.js pageflow/editor.css | ||
pageflow/application_with_simulated_media_queries.css | ||
pageflow/print_view.css | ||
pageflow/lt_ie9.js pageflow/lt_ie9.css pageflow/ie9.js pageflow/ie9.css |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Align the elements of an array literal if they span more than one line.
Line is too long. [108/100]
lib/pageflow/engine.rb
Outdated
initializer 'pageflow.assets.precompile' do |app| | ||
app.config.assets.precompile += %w(pageflow/editor.js pageflow/editor.css | ||
pageflow/application_with_simulated_media_queries.css | ||
pageflow/print_view.css |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Align the elements of an array literal if they span more than one line.
lib/pageflow/engine.rb
Outdated
# provided by the main app. | ||
initializer 'pageflow.assets.precompile' do |app| | ||
app.config.assets.precompile += %w(pageflow/editor.js pageflow/editor.css | ||
pageflow/application_with_simulated_media_queries.css |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Align the elements of an array literal if they span more than one line.
lib/pageflow/engine.rb
Outdated
end | ||
end | ||
|
||
app.config.assets.precompile << lambda do |path, filename| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent indentation detected.
lib/pageflow/engine.rb
Outdated
pageflow/vendor.js | ||
video-js.swf vjs.eot vjs.svg vjs.ttf vjs.woff) | ||
|
||
app.config.assets.precompile << lambda do |path, _filename| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent indentation detected.
lib/pageflow/engine.rb
Outdated
pageflow/print_view.css | ||
pageflow/lt_ie9.js pageflow/lt_ie9.css pageflow/ie9.js pageflow/ie9.css | ||
pageflow/vendor.js | ||
video-js.swf vjs.eot vjs.svg vjs.ttf vjs.woff) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Align the elements of an array literal if they span more than one line.
lib/pageflow/engine.rb
Outdated
pageflow/application_with_simulated_media_queries.css | ||
pageflow/print_view.css | ||
pageflow/lt_ie9.js pageflow/lt_ie9.css pageflow/ie9.js pageflow/ie9.css | ||
pageflow/vendor.js |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Align the elements of an array literal if they span more than one line.
lib/pageflow/engine.rb
Outdated
app.config.assets.precompile += %w(pageflow/editor.js pageflow/editor.css | ||
pageflow/application_with_simulated_media_queries.css | ||
pageflow/print_view.css | ||
pageflow/lt_ie9.js pageflow/lt_ie9.css pageflow/ie9.js pageflow/ie9.css |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Align the elements of an array literal if they span more than one line.
Line is too long. [108/100]
lib/pageflow/engine.rb
Outdated
initializer 'pageflow.assets.precompile' do |app| | ||
app.config.assets.precompile += %w(pageflow/editor.js pageflow/editor.css | ||
pageflow/application_with_simulated_media_queries.css | ||
pageflow/print_view.css |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Align the elements of an array literal if they span more than one line.
lib/pageflow/engine.rb
Outdated
# provided by the main app. | ||
initializer 'pageflow.assets.precompile' do |app| | ||
app.config.assets.precompile += %w(pageflow/editor.js pageflow/editor.css | ||
pageflow/application_with_simulated_media_queries.css |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Align the elements of an array literal if they span more than one line.
lib/pageflow/engine.rb
Outdated
end | ||
end | ||
|
||
app.config.assets.precompile << lambda do |path, filename| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent indentation detected.
lib/pageflow/engine.rb
Outdated
pageflow/vendor.js | ||
video-js.swf vjs.eot vjs.svg vjs.ttf vjs.woff) | ||
|
||
app.config.assets.precompile << lambda do |path, _filename| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent indentation detected.
lib/pageflow/engine.rb
Outdated
pageflow/print_view.css | ||
pageflow/lt_ie9.js pageflow/lt_ie9.css pageflow/ie9.js pageflow/ie9.css | ||
pageflow/vendor.js | ||
video-js.swf vjs.eot vjs.svg vjs.ttf vjs.woff) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Align the elements of an array literal if they span more than one line.
lib/pageflow/engine.rb
Outdated
pageflow/application_with_simulated_media_queries.css | ||
pageflow/print_view.css | ||
pageflow/lt_ie9.js pageflow/lt_ie9.css pageflow/ie9.js pageflow/ie9.css | ||
pageflow/vendor.js |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Align the elements of an array literal if they span more than one line.
lib/pageflow/engine.rb
Outdated
app.config.assets.precompile += %w(pageflow/editor.js pageflow/editor.css | ||
pageflow/application_with_simulated_media_queries.css | ||
pageflow/print_view.css | ||
pageflow/lt_ie9.js pageflow/lt_ie9.css pageflow/ie9.js pageflow/ie9.css |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Align the elements of an array literal if they span more than one line.
Line is too long. [108/100]
lib/pageflow/engine.rb
Outdated
initializer 'pageflow.assets.precompile' do |app| | ||
app.config.assets.precompile += %w(pageflow/editor.js pageflow/editor.css | ||
pageflow/application_with_simulated_media_queries.css | ||
pageflow/print_view.css |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Align the elements of an array literal if they span more than one line.
lib/pageflow/engine.rb
Outdated
# provided by the main app. | ||
initializer 'pageflow.assets.precompile' do |app| | ||
app.config.assets.precompile += %w(pageflow/editor.js pageflow/editor.css | ||
pageflow/application_with_simulated_media_queries.css |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Align the elements of an array literal if they span more than one line.
@tf changes done & rebased |
1 similar comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Specs are failing since Teaspoon does not load the new vendor.js
file.
lib/pageflow/engine.rb
Outdated
filename.start_with?(Engine.root.join('app/assets').to_s) && | ||
!['.js', '.css', ''].include?(File.extname(path)) | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What difference does wrapping the code in an initializer
block make here? Can we fix indentation here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just following the documented API for engine asset precompilation. Pretty sure this will handle a tweaked asset pipeline better.
Indentation fixed.
@@ -0,0 +1,16 @@ | |||
// vendor stylesheet for Pageflow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"stylesheet" is a typo.
lib/pageflow/engine.rb
Outdated
end | ||
|
||
app.config.assets.precompile << lambda do |path, filename| | ||
filename.start_with?(Engine.root.join('app/assets').to_s) && !['.js', '.css', ''].include?(File.extname(path)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [118/100]
I am not too familiar with Teaspoon, how do I fix that? Other changes are done. |
Tried to push a commit to the PR, but maybe the option is not set. Here's the diff, that makes teaspoon pass: https://github.com/scrollytelling/pageflow/compare/vendor-app-javascript...tf:vendor-app-javascript |
I've merged in your commits. |
Travis appears to be stuck somehow... |
These will be compiled separately. Since they change less often, the idea is that these assets will remain in cache for longer.
@tf squashed all the commits (including yours). |
Thanks. I'd totally merge, but I want the green check mark on the PR first ;) I don't know why Travis stopped picking up changes, but worst case we'll have to create a fresh PR from the same branch. |
I'll create a new PR tomorrow if it doesn't go through today. |
This pattern is quite common for Webpack and it makes a lot of sense to me too.
We split up application.js into a vendor part and an app part. The engine precompiles both. They are meant to be included separately into the html . Vendor won't change nearly as often and so will remain cached for longer.
It's backwards compatible with the current way. I'll update docs etc if you think this is a good idea.