Skip to content

Conversation

@randallreedjr
Copy link
Contributor

@randallreedjr randallreedjr commented Jun 25, 2018

Rationale

I am currently using critical-path-css-rails to generate the critical CSS for a react on rails project using webpack to package our assets. We are using the ExtractTextPlugin to separate the CSS for each page to minimize load. We successfully deployed critical-path-css-rails for one of our pages, but cannot easily apply it to additional pages without a way to handle multiple CSS paths.

Implementation

This is the simplest implementation that occurred to me. It adds a new key, css _paths, which is mutually exclusive from the existing key css_path. Like routes, css_paths can be a list of css files that correspond to the routes; we assume they are in the same respective order. Therefore, both arrays should be the same length.

This change is backwards compatible, so existing users should not experience a breaking change.

The PR also updates the README to address #31.

Tasks

  • Add new key css_paths to specify separate css path per route
  • Add error checking to ensure css_paths is used correctly
  • Clarify error messages
  • Update Configuration to add new key to config object
  • Update CssFetcher to pass separate css_path to each Penthouse invocation
  • Update generator to add css_paths key
  • Add text to test page that is always visible
  • Bump version
  • Squash before merging

* Ensure only one css_path configuration is used
* Raise error if length of css_paths does not match routes
* Add comment in config file about css_paths
@michael-misshore
Copy link
Contributor

@randallreedjr Thanks for the PR! I've been taking a look at this, and I have some feedback. I'll try to post all my feedback by this weekend. One thing that I'd like to see done is the new css_paths config added to the Usage section in the Readme, along with the other config options. That would be a huge help!

I have a few edit suggestions for the tests (which we can always refactor later so not terribly critical), css_fetcher.rb, and config_loader.rb. I'll try to post them as quickly as possible.

@randallreedjr
Copy link
Contributor Author

Cool, thanks @michael-misshore! I really appreciate your responsiveness. I'll get cracking on your feedback as soon as I can.

@dg-rr
Copy link

dg-rr commented Jul 12, 2018

@michael-misshore Friendly reminder for feedback :)

@michael-misshore
Copy link
Contributor

@dm-randy Thanks and sorry!. @randallreedjr Your changes gave me some ideas for some refactors. I started working on this before the holiday, and I'll try to have something that can be reviewed and merged into your branch sometime soon.

@randallreedjr
Copy link
Contributor Author

Oops, both of those accounts are me

@randallreedjr
Copy link
Contributor Author

@michael-misshore I just pushed an update with an addition to the README. Any feedback from your end?

@michael-misshore
Copy link
Contributor

@randallreedjr README changes look good. Did you see the review I started regarding config_loader_spec.rb? I'd like to hear your feedback (and any changes you make) on it.

@randallreedjr
Copy link
Contributor Author

@michael-misshore Hm, not sure what's going on, but I don't see any reviews

end

context 'when single css_path is specified' do
let(:config_file) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@randallreedjr, Is it possible to move this config into a fixture of sorts? I think it may help improve the readability and clean up this spec if we were able to write something like let(:config_file) { File.open('/path/to/single_css_path_conf.yml') } or something along those lines. Not sure if a fixture is the right call or just moving the config into a file in a config directory. Likewise, the same can be done with the other similar config variables.

Once this is address, I'll go ahead and merge this in and tag you with the merge request that has the refactors in it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@randallreedjr Can you see my above message?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@michael-misshore Yep, will do!

@michael-misshore michael-misshore merged commit f505de0 into mudbugmedia:master Dec 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants