Last active
December 23, 2015 06:49
-
-
Save ehelms/6596261 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module SpliceReports | |
class Engine < Rails::Engine | |
initializer :register_assets do |engine| | |
if Rails.env.production? | |
assets = YAML.load_file("#{SpliceReports::Engine.root}/public/assets/manifest.yml") | |
assets.each_pair do |file, digest| | |
engine.config.assets.digests[file] = digest | |
end | |
end | |
engine.middleware.use ::ActionDispatch::Static, "#{SpliceReports::Engine.root}/public" | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
desc 'Compile stand alone engine assets' | |
task 'assets:precompile:engine' do | |
require 'sprockets' | |
require 'sprockets/railtie' | |
require 'uglifier' | |
require 'sass/rails/compressor' | |
require File.expand_path('../lib/splice_reports', __FILE__) | |
precompile = [ | |
'splice_reports/splice.css', | |
'splice_reports/splice_reports.js' | |
] | |
env = Sprockets::Environment.new(SpliceReports::Engine.root) | |
env.js_compressor = Uglifier.new | |
env.css_compressor = Sass::Rails::CssCompressor.new | |
paths = [ | |
'app/assets/stylesheets', | |
'app/assets/javascripts' | |
] | |
paths.each do |path| | |
env.append_path(path) | |
end | |
target = File.join(SpliceReports::Engine.root, 'public', 'assets') | |
compiler = Sprockets::StaticCompiler.new(env, | |
target, | |
precompile, | |
:manifest_path => File.join(target), | |
:digest => true, | |
:manifest => true) | |
compiler.compile | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment