Provides the ability to skip minification of some JS assets.
This commit is contained in:
parent
3bcaaf6960
commit
3aa165d3b6
|
@ -53,6 +53,9 @@ module Discourse
|
|||
|
||||
config.assets.paths += %W(#{config.root}/config/locales #{config.root}/public/javascripts)
|
||||
|
||||
# Allows us to skip minifincation on some files
|
||||
config.assets.skip_minification = []
|
||||
|
||||
# explicitly precompile any images in plugins ( /assets/images ) path
|
||||
config.assets.precompile += [lambda do |filename, path|
|
||||
path =~ /assets\/images/ && !%w(.js .css).include?(File.extname(filename))
|
||||
|
|
|
@ -136,6 +136,8 @@ task 'assets:precompile' => 'assets:precompile:before' do
|
|||
if $node_uglify
|
||||
puts "Compressing Javascript and Generating Source Maps"
|
||||
manifest = Sprockets::Manifest.new(assets_path)
|
||||
|
||||
to_skip = Rails.configuration.assets.skip_minification || []
|
||||
manifest.files
|
||||
.select{|k,v| k =~ /\.js$/}
|
||||
.each do |file, info|
|
||||
|
@ -148,14 +150,17 @@ task 'assets:precompile' => 'assets:precompile:before' do
|
|||
STDERR.puts "Skipping: #{file} already compressed"
|
||||
else
|
||||
STDERR.puts "Compressing: #{file}"
|
||||
FileUtils.mv(path, _path)
|
||||
compress(_file,file)
|
||||
|
||||
# We can specify some files to never minify
|
||||
unless to_skip.include?(info['logical_path'])
|
||||
FileUtils.mv(path, _path)
|
||||
compress(_file,file)
|
||||
end
|
||||
|
||||
info["size"] = File.size(path)
|
||||
info["mtime"] = File.mtime(path).iso8601
|
||||
gzip(path)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# protected
|
||||
|
|
Loading…
Reference in New Issue