File tree 1 file changed +33
-0
lines changed
1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change
1
+ # First need to import Dashing with the Smashing Sinatra App
2
+ require 'dashing'
3
+ # Then import Sinatra, which will prepare sprockets settings
4
+ require 'sinatra'
5
+ # Now match the imports from Smashing's app.rb so that the resources are pre-processed
6
+ require 'coffee-script'
7
+ require 'sass' if RUBY_VERSION < "2.5.0"
8
+ require 'sassc' if RUBY_VERSION >= "2.5.0"
9
+ # Logger and misc
10
+ require 'pathname'
11
+ require 'logger'
12
+
13
+ # From: https://simonecarletti.com/blog/2011/09/using-sprockets-without-a-railsrack-project/
14
+ ROOT = Pathname ( File . dirname ( __FILE__ ) )
15
+ LOGGER = Logger . new ( STDOUT )
16
+ BUNDLES = %w( application.js )
17
+ BUILD_DIR = ROOT . join ( "assets/javascripts/" )
18
+
19
+ # This contains the settings from the Smashign Sinatra App (see app.rb)
20
+ # so no need to append_path, etc.
21
+ sprockets = Sinatra ::Application . settings . sprockets
22
+ sprockets . logger = LOGGER
23
+
24
+ # Task: precompile-assets
25
+ # Pre-compiles sprockets application.js so users don't need to wait for Sinatra/Sprockets
26
+ # to generate it on the fly.
27
+ # see: https://github.com/Smashing/smashing/issues/189
28
+ task :'precompile-assets' do
29
+ BUNDLES . each do |bundle |
30
+ asset = sprockets . find_asset ( bundle )
31
+ asset . write_to ( BUILD_DIR . join ( asset . logical_path ) )
32
+ end
33
+ end
You can’t perform that action at this time.
0 commit comments