diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 0000000..91b81b8 --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,39 @@ +'use strict'; + +module.exports = function(grunt) { + + // Project configuration. + grunt.initConfig({ + // Metadata. + pkg: grunt.file.readJSON('package.json'), + banner: grunt.file.read('copy.js'), + // Task configuration. + concat: { + options: { + banner: '<%= banner %>', + stripBanners: true + }, + dist: { + src: ['./eve/eve.js', 'raphael.core.js', 'raphael.svg.js', 'raphael.vml.js'], + dest: '<%= pkg.name %>.js' + }, + }, + uglify: { + options: { + banner: '<%= banner %>' + }, + dist: { + src: '<%= concat.dist.dest %>', + dest: '<%= pkg.name %>-min.js' + }, + }, + }); + + // These plugins provide necessary tasks. + grunt.loadNpmTasks('grunt-contrib-concat'); + grunt.loadNpmTasks('grunt-contrib-uglify'); + + + // Default task. + grunt.registerTask('default', ['concat', 'uglify']); +}; diff --git a/README.markdown b/README.markdown index 1f2aba6..7860260 100644 --- a/README.markdown +++ b/README.markdown @@ -9,6 +9,7 @@ Visit the library website for more information: [http://raphaeljs.com](http://ra (thank you [Wes Tood](https://github.com/wesleytodd)) ## Dependencies +* [grunt](https://github.com/gruntjs/grunt) * [uglifyjs](https://github.com/mishoo/UglifyJS) * [eve](https://github.com/adobe-webplatform/eve) @@ -52,7 +53,7 @@ We are organizing the current issues between this milestones, setting the ground All changes in code must go to `raphael.core`, `raphael.svg` or `raphael.vml`. `raphael.js` is a generated file. -After adding your changes, execute `./make`, the minified version will be created, commit and you are ready to make a pull request! +After adding your changes, execute `grunt`, the minified version will be created, commit and you are ready to make a pull request! ## Found an issue? diff --git a/copy.js b/copy.js index 1837442..8928ada 100644 --- a/copy.js +++ b/copy.js @@ -5,4 +5,4 @@ // │ Copyright © 2008-2012 Sencha Labs (http://sencha.com) │ \\ // ├────────────────────────────────────────────────────────────────────┤ \\ // │ Licensed under the MIT (http://raphaeljs.com/license.html) license.│ \\ -// └────────────────────────────────────────────────────────────────────┘ \\ \ No newline at end of file +// └────────────────────────────────────────────────────────────────────┘ \\ diff --git a/make b/make deleted file mode 100755 index e883efe..0000000 --- a/make +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env node -var ujs = require('uglify-js'), - fs = require('fs'), - input = { - core : 'raphael.core.js', - svg : 'raphael.svg.js', - vml : 'raphael.vml.js', - eve : './eve/eve.js', - copy : 'copy.js' - }, - output = { - 'raphael-min.js' : ['eve', 'core', 'svg', 'vml'], - 'raphael.js' : ['eve', 'core', 'svg', 'vml'] - }; - -for (var file in input) { - input[file] = fs.readFileSync(input[file], 'utf8'); -} -for (file in output) { - var out = ''; - if (file.indexOf('min') !== -1) { - console.log('Compressing ' + file); - for (var i = 0, l = output[file].length; i < l; i++) { - var o = ujs.minify(input[output[file][i]], { - fromString : true - }); - out += o.code; - } - } else { - console.log('Concatinating ' + file); - for (i = 0, l = output[file].length; i < l; i++) { - out += input[output[file][i]] + '\n'; - } - } - (function(f, code){ - fs.writeFile(f, input.copy + '\n' + code, function(err) { - if (err) { - console.log(err); - } else { - console.log('Saved to \033[32m' + f + '\033[0m\n'); - } - }); - })(file, out); -} diff --git a/package.json b/package.json index 06f6c19..69a66e0 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,9 @@ "readmeFilename": "README.markdown", "gitHead": "52bff469f60988f1391e8b3d7cb5349163df8ba1", "devDependencies": { - "uglify-js": "~2.2.3" + "grunt-cli": "~0.1.7", + "grunt": "~0.4.1", + "grunt-contrib-uglify": "~0.2.0", + "grunt-contrib-concat": "~0.3.0" } }