Fixes#2
Conversation
|
|
||
| delegate :request, :params, to: :template | ||
|
|
||
| def initialize(template, manifest: template.asset_url('application.css'), version: Config.version, skip: false, cache: true, &block) |
There was a problem hiding this comment.
The way this is written you should be able to override the name of the manifest manually when you call this method. I call it like this:
= RailsCriticalCssServer::Rewrite.call(self,
skip: current_user.present?,
manifest: asset_url('css_manifest.css')) do
There was a problem hiding this comment.
true. but then you have the manifest name twice in your template and it doesn't handle the generated hash in the filename.
There was a problem hiding this comment.
The generated hash will be added to the filename, since the asset_url helper is smart enough to generate the correct digest and everything in a production environment.
This approach will also break because you may have more than one stylesheet in your HTML; for instance in one of my apps I have to split my css files up to avoid IE9 rule limit restrictions. So I have something like this:
= RailsCriticalCssServer::Rewrite.call(self,
manifest: asset_url('css_manifest.css')) do
= stylesheet_link_tag 'bootstrap'
= stylesheet_link_tag 'common'
= stylesheet_link_tag 'page_rules'
css_manifest.css in this case is a single stylesheet with all the rules, in an easy format that criticalcss can read.
Here's a cleaned up version of the previous PR:
Some minor things:
A bit more major:
removes manifest arg and defines a method to get the current stylesheet. Basically, this was previously set up to only work with stylesheets named 'application.css' -- and it seemed, at least for me, to pass the string 'application.css' to the node server -- when in fact the file name had a hash on it - e.g. application-fab7daa9310cc448046aee95dccad8018095b572b53077b78bc4b8bc8545c5bf
I've had this branch running for a week or so now and it seems to be working well.