Sha256: ad6d47adfde9d7df8236820ea7bef5db110d89eaaceaca716fe0c95c32d18248

Contents?: true

Size: 1.6 KB

Versions: 11

Compression:

Stored size: 1.6 KB

Contents

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

require_relative 'load_sprockets'

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

Plugin = Fanforce::Plugin
Plugin.config.load_env

PluginWorker = Fanforce::PluginWorker

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

namespace :assets do

  desc 'Precompile assets for production'
  task :precompile => :clean do
    config = Plugin.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(Plugin.config.base_dir, '/public/assets')
    puts 'DONE'
  end

  task :test do
    puts 'TEST WORKED!'
  end

end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
fanforce-plugin-factory-2.0.0.rc3 lib/fanforce/plugin_factory/Rakefile
fanforce-plugin-factory-1.6.1 lib/fanforce/plugin_factory/Rakefile
fanforce-plugin-factory-2.0.0.rc2 lib/fanforce/plugin_factory/Rakefile
fanforce-plugin-factory-2.0.0.rc1 lib/fanforce/plugin_factory/Rakefile
fanforce-plugin-factory-1.6.0 lib/fanforce/plugin_factory/Rakefile
fanforce-plugin-factory-1.6.0.rc6 lib/fanforce/plugin_factory/Rakefile
fanforce-plugin-factory-1.6.0.rc5 lib/fanforce/plugin_factory/Rakefile
fanforce-plugin-factory-1.6.0.rc4 lib/fanforce/plugin_factory/Rakefile
fanforce-plugin-factory-1.6.0.rc3 lib/fanforce/plugin_factory/Rakefile
fanforce-plugin-factory-1.6.0.rc2 lib/fanforce/plugin_factory/Rakefile
fanforce-plugin-factory-1.6.0.rc1 lib/fanforce/plugin_factory/Rakefile