Sha256: 065fa6e77f576a92f5e5ed60336ac4619e7c10275e0149fb4508272f0743e72f

Contents?: true

Size: 1.58 KB

Versions: 13

Compression:

Stored size: 1.58 KB

Contents

require 'fileutils'
require 'json'
require 'yaml'

require_relative 'load_sprockets'

########################################################################################################################

App = Fanforce::App
App.config.load_env

AppWorker = Fanforce::AppWorker

########################################################################################################################

namespace :assets do

  desc 'Precompile assets for production'
  task :precompile => :clean do
    config = App.config
    sprockets = SprocketsCompiler.setup(config.base_dir)

    puts 'PRECOMPILING ASSETS... '
    SprocketsCompiler.new(sprockets: sprockets, precompile: [/(\/|^)[^_\/]+[^\/]*\.(css|js|png|gif|jpeg|jpg|otf|eot|svg|ttf|woff)/]).compile
    puts 'DONE'

    print 'GENERATING ASSET MANIFESTS... '
    asset_list = {}
    sprockets.each_logical_path do |logical_path|
      if File.basename(logical_path) !~ /^[_]/ and asset = sprockets.find_asset(logical_path)
        asset_list[logical_path] = "/assets/#{asset.digest_path}"
      end
    end
    IO.write File.join(config.base_dir, '/public/asset_manifest.json'), JSON.generate(asset_list)
    IO.write File.join(config.base_dir, '/public/asset_manifest.json'), "ASSETS=#{JSON.generate(asset_list)}"
    IO.write File.join(config.base_dir, '/public/asset_manifest.json'), asset_list.to_yaml
    puts 'DONE'
  end

  desc 'Clean assets folder'
  task :clean do
    print 'DESTROYING PUBLIC/ASSETS... '
    FileUtils.rm_rf File.join(App.config.base_dir, '/public/assets')
    puts 'DONE'
  end

  task :test do
    puts 'TEST WORKED!'
  end

end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
fanforce-app-factory-2.0.0.rc38 lib/fanforce/app_factory/Rakefile
fanforce-app-factory-2.0.0.rc37 lib/fanforce/app_factory/Rakefile
fanforce-app-factory-2.0.0.rc36 lib/fanforce/app_factory/Rakefile
fanforce-app-factory-2.0.0.rc35 lib/fanforce/app_factory/Rakefile
fanforce-app-factory-2.0.0.rc34 lib/fanforce/app_factory/Rakefile
fanforce-app-factory-2.0.0.rc33 lib/fanforce/app_factory/Rakefile
fanforce-app-factory-2.0.0.rc32 lib/fanforce/app_factory/Rakefile
fanforce-app-factory-2.0.0.rc31 lib/fanforce/app_factory/Rakefile
fanforce-app-factory-2.0.0.rc30 lib/fanforce/app_factory/Rakefile
fanforce-app-factory-2.0.0.rc29 lib/fanforce/app_factory/Rakefile
fanforce-app-factory-2.0.0.rc27 lib/fanforce/app_factory/Rakefile
fanforce-app-factory-2.0.0.rc26 lib/fanforce/app_factory/Rakefile
fanforce-app-factory-2.0.0.rc25 lib/fanforce/app_factory/Rakefile