Commit ef763bef authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Add Rake task for compressing JavaScript files.

Using the sencha SDK tools.
parent 4f6bb8a8
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -155,4 +155,23 @@ task :docs do
  ])
end

# Note: This should be run *after* running the :export or :live_docs task
desc "Compresses JavaScript files in output dir"
task :compress do
  load_sdk_vars
  # Create JSB3 file for Docs app
  system("sencha", "create", "jsb", "-a", "#{OUT_DIR}/index.html", "-p", "#{OUT_DIR}/app.jsb3")
  # Concatenate files listed in JSB3 file
  system("sencha", "build", "-p", "#{OUT_DIR}/app.jsb3", "-d", OUT_DIR)
  # Replace Copyright information in compressed file, writing new version to original app.js
  copy = 'Generated by JSDuck: https:\/\/github.com\/senchalabs\/jsduck'
  system("sed 's/^Copyright.*Company Name$/#{copy}/' #{OUT_DIR}/app-all.js > #{OUT_DIR}/app.js")
  # Remove intermediate build files
  system("rm", "#{OUT_DIR}/app.jsb3")
  system("rm", "#{OUT_DIR}/all-classes.js")
  system("rm", "#{OUT_DIR}/app-all.js")
  # Remove the entire app/ dir
  system("rm", "-r", "#{OUT_DIR}/app")
end

task :default => :spec