Class: Sprockets::Standalone::RakeTask
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- Sprockets::Standalone::RakeTask
- Defined in:
- lib/sprockets/standalone.rb
Instance Attribute Summary collapse
-
#assets ⇒ Object
List of sprocket file targets that should be compiled.
-
#compress ⇒ Object
If assets should be compressed.
-
#digest ⇒ Object
If assets should include digest.
-
#environment ⇒ Object
‘Environment` instance used for finding assets.
-
#output ⇒ Object
Set output directory.
-
#sources ⇒ Object
List of source directories.
Instance Method Summary collapse
- #index ⇒ Object
-
#initialize(*args) {|_self, environment| ... } ⇒ RakeTask
constructor
A new instance of RakeTask.
- #manifest ⇒ Object
Constructor Details
#initialize(*args) {|_self, environment| ... } ⇒ RakeTask
Returns a new instance of RakeTask.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/sprockets/standalone.rb', line 45 def initialize(*args) @namespace = args.shift || :assets @assets = %w(application.js application.css *.png *.jpg *.gif) @sources = [] @output = File.('dist', Dir.pwd) @digest = false @compress = false @environment = Sprockets::Environment.new(Dir.pwd) do |env| env.logger = Logger.new $stdout env.logger.level = Logger::INFO end yield self, environment if block_given? Array(sources).each { |source| environment.append_path source } manifest.compress_assets = !!@compress manifest.digest_assets = !!@digest namespace @namespace do desc 'Compile assets' task :compile do manifest.compile *Array(assets) end desc 'Remove all assets' task :clobber do manifest.clobber end desc 'Clean old assets' task :clean do manifest.clean end end end |
Instance Attribute Details
#assets ⇒ Object
List of sprocket file targets that should be compiled.
11 12 13 |
# File 'lib/sprockets/standalone.rb', line 11 def assets @assets end |
#compress ⇒ Object
If assets should be compressed. Default is false.
32 33 34 |
# File 'lib/sprockets/standalone.rb', line 32 def compress @compress end |
#digest ⇒ Object
If assets should include digest. Default is false.
29 30 31 |
# File 'lib/sprockets/standalone.rb', line 29 def digest @digest end |
#environment ⇒ Object
‘Environment` instance used for finding assets.
35 36 37 |
# File 'lib/sprockets/standalone.rb', line 35 def environment @environment end |
#output ⇒ Object
Set output directory. Defaults to ‘dist` in current working directory.
26 27 28 |
# File 'lib/sprockets/standalone.rb', line 26 def output @output end |
#sources ⇒ Object
List of source directories. This is a convenience method as it will add all available sub-directories like ‘stylesheets`, `javascripts` to sprockets include path.
Example: If you have a typical sprockets directory layout like ‘src/assets/stylesheets`, `src/assets/javascripts` all you need to add to `source` is `src/assets`.
22 23 24 |
# File 'lib/sprockets/standalone.rb', line 22 def sources @sources end |
Instance Method Details
#index ⇒ Object
37 38 39 |
# File 'lib/sprockets/standalone.rb', line 37 def index @index ||= environment.index if environment end |
#manifest ⇒ Object
41 42 43 |
# File 'lib/sprockets/standalone.rb', line 41 def manifest @manifest ||= Sprockets::Standalone::Manifest.new index, File.join(output, "manifest.json") end |