Sha256: 1d0573e0c4aef9e6947efd002ed206cb5fd484e7e9e50bd701867e926c97ad3a

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

require 'bundler'
Bundler.require
Bundler::GemHelper.install_tasks

require 'opal/rspec/rake_task'
Opal::RSpec::RakeTask.new(:default) do |s|
  s.index_path = 'spec/jquery/index.html.erb'
end

Opal::RSpec::RakeTask.new(:zepto) do |s|
  s.index_path = 'spec/zepto/index.html.erb'
end

desc "Build build/opal-jquery.js"
task :dist do
  require 'fileutils'
  FileUtils.mkdir_p 'build'

  src = Opal::Builder.build('opal-jquery')
  min = uglify src
  gzp = gzip min

  File.open('build/opal-jquery.js', 'w+') do |out|
    out << src
  end

  puts "development: #{src.size}, minified: #{min.size}, gzipped: #{gzp.size}"
end

# Used for uglifying source to minify
def uglify(str)
  IO.popen('uglifyjs', 'r+') do |i|
    i.puts str
    i.close_write
    return i.read
  end
rescue Errno::ENOENT
  $stderr.puts '"uglifyjs" command not found (install with: "npm install -g uglify-js")'
  nil
end

# Gzip code to check file size
def gzip(str)
  IO.popen('gzip -f', 'r+') do |i|
    i.puts str
    i.close_write
    return i.read
  end
rescue Errno::ENOENT
  $stderr.puts '"gzip" command not found, it is required to produce the .gz version'
  nil
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
opal-jquery-0.2.0 Rakefile