File tree Expand file tree Collapse file tree 2 files changed +19
-7
lines changed
generators/critical_path_css Expand file tree Collapse file tree 2 files changed +19
-7
lines changed Original file line number Diff line number Diff line change @@ -4,13 +4,10 @@ module CriticalPathCss
4
4
class InstallGenerator < Rails ::Generators ::Base
5
5
source_root File . expand_path ( '..' , __FILE__ )
6
6
7
- # Copy all needed stylesheets in the asset directory of the application
8
- def copy_stylesheets
9
- FileUtils . mkdir_p "app/assets/stylesheets/bootstrap_overrides"
10
-
11
- copy_file "../../../app/assets/stylesheets/twitter/bootstrap.css.scss" , "app/assets/stylesheets/bootstrap_overrides/base.css.scss"
12
- copy_file "../../../app/assets/stylesheets/twitter/bootstrap/_variables.scss" , "app/assets/stylesheets/bootstrap_overrides/variables.css.scss"
13
- copy_file "templates/bootstrap_overrides.css.scss" , "app/assets/stylesheets/bootstrap_overrides/bootstrap_overrides.css.scss"
7
+ # Copy the needed rake task for generating critical CSS
8
+ def copy_rake_task
9
+ task_filename = 'critical_path_css.rake'
10
+ copy_file "../../tasks/#{ task_filename } " , "lib/tasks/#{ task_filename } "
14
11
end
15
12
end
16
13
end
Original file line number Diff line number Diff line change
1
+ require 'critical-path-css'
2
+
3
+ namespace :critical_path_css do
4
+ @base_url = Rails . env . production? ? 'http://example.com' : 'http://localhost:3000'
5
+ @routes = %w{
6
+ /
7
+ }
8
+
9
+ desc "Generate critical CSS for the routes defined"
10
+ task :generate => :environment do
11
+ @main_css_path = ActionController ::Base . helpers . stylesheet_path ( 'application.css' ) . to_s
12
+
13
+ CriticalPathCss . generate ( @main_css_path , @base_url , @routes )
14
+ end
15
+ end
You can’t perform that action at this time.
0 commit comments