Create a build script to concatenate and (optionaly) minify the files in the lib directory.

This commit is contained in:
Antoine Proulx 2012-03-05 20:59:41 -05:00
parent 2a1acc3477
commit ac802613a8
7 changed files with 100 additions and 2 deletions

4
Gemfile Normal file
View File

@ -0,0 +1,4 @@
source :rubygems
gem 'rake'
gem 'uglifier'

17
Gemfile.lock Normal file
View File

@ -0,0 +1,17 @@
GEM
remote: http://rubygems.org/
specs:
execjs (1.3.0)
multi_json (~> 1.0)
multi_json (1.1.0)
rake (0.9.2.2)
uglifier (1.2.3)
execjs (>= 0.3.0)
multi_json (>= 1.0.2)
PLATFORMS
ruby
DEPENDENCIES
rake
uglifier

View File

@ -8,3 +8,11 @@ You can draw your own shapes or images using the existing canvas API, add event
# Tutorials
Check out the official [KineticJS Tutorials](http://www.html5canvastutorials.com/kineticjs/html5-canvas-events-tutorials-introduction-with-kineticjs/) hosted on [HTML5 Canvas Tutorials](http://www.html5canvastutorials.com/).
# Building the library
To build the library, you need to have Ruby and Rubygems installed. After that, install the dependencies by running `bundle install`.
To build a development version of the library, run `rake build:dev`. To build a minify version of the library, run `rake build:prod`.
# Adding a new file in the lib directory
If you add a file in the lib directory, add into the array in the Rakefile.

37
Rakefile Normal file
View File

@ -0,0 +1,37 @@
# This is the list of files to concatenate. The first file will appear at the top of the final file. All files are relative to the lib directory.
FILES = [
"Kinetic.js", "GlobalObject.js", "Node.js", "Container.js", "Stage.js",
"Layer.js", "Group.js", "Shape.js", "Rect.js", "Circle.js", "Image.js",
"Polygon.js", "RegularPolygon.js", "Star.js", "Text.js"
]
def concatenate
content = ""
FILES.each do |file|
content << IO.read(File.expand_path('lib/' + file)) << "\n"
end
return content
end
namespace :build do
desc "Concatenate all the files in /lib into /dist/kinetic.js."
task :dev do
puts ":: Building the file /dist/kinetic.js..."
File.open("dist/kinetic.js", "w") do |file|
file.puts concatenate()
end
puts " -> Done!"
end
desc "Concatenate all the files in /lib into /dist/kinetic.min.js and minify it."
task :prod do
puts ":: Building the file /dist/kinetic.min.js..."
require 'uglifier'
File.open("dist/kinetic.min.js", "w") do |file|
file.puts Uglifier.compile(concatenate())
end
puts ":: Minifying the file /dist/kinetic.min.js..."
puts " -> Done!"
end
end

5
dist/kinetic.js vendored
View File

@ -25,6 +25,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
///////////////////////////////////////////////////////////////////////
// Global Object
///////////////////////////////////////////////////////////////////////
@ -120,6 +121,7 @@ window.requestAnimFrame = (function(callback){
};
})();
///////////////////////////////////////////////////////////////////////
// Node
///////////////////////////////////////////////////////////////////////
@ -1835,7 +1837,6 @@ Kinetic.Polygon.prototype = {
// extend Shape
Kinetic.GlobalObject.extend(Kinetic.Polygon, Kinetic.Shape);
///////////////////////////////////////////////////////////////////////
// RegularPolygon
///////////////////////////////////////////////////////////////////////
@ -1889,7 +1890,6 @@ Kinetic.RegularPolygon.prototype = {
// extend Shape
Kinetic.GlobalObject.extend(Kinetic.RegularPolygon, Kinetic.Shape);
///////////////////////////////////////////////////////////////////////
// Star
///////////////////////////////////////////////////////////////////////
@ -2098,3 +2098,4 @@ Kinetic.Text.prototype = {
};
// extend Shape
Kinetic.GlobalObject.extend(Kinetic.Text, Kinetic.Shape);

31
dist/kinetic.min.js vendored Normal file

File diff suppressed because one or more lines are too long