Skip to content
Permalink
Browse files
quick build script to bundle everything together for the web
  • Loading branch information
gtanner committed Nov 15, 2011
1 parent c1587da commit fafcf2fcf7026370a6d674b6db88c50730e7d389
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 2 deletions.
@@ -0,0 +1,2 @@
pkg/
tags
@@ -1,3 +1,6 @@
[submodule "thirdparty/browser-require"]
path = thirdparty/browser-require
url = https://github.com/rsms/browser-require.git
[submodule "node_modules/uglify-js"]
path = node_modules/uglify-js
url = https://github.com/mishoo/UglifyJS.git
@@ -1,12 +1,53 @@
var DEPLOY = __dirname + "/pkg/";

desc("runs build");
task('default', ['build'], function () {});

desc("clean");
task('clean', [], function () {
var childProcess = require('child_process');

var cmd = 'rm -rf ' + DEPLOY + ' && ' +
'mkdir ' + DEPLOY;

childProcess.exec(cmd, complete);
}, true);

desc("compiles the source files for all extensions");
task('build', [], function () {
task('build', ['clean'], function () {

var util = require('util'),
fs = require('fs');
fs = require('fs'),
files = [
"lib/Channel.js",
"lib/utils.js",
"lib/exec/blackberry.js"
],
include = function (files, transform) {
files = files.map ? files : [files];
return files.map(function (file) {
var str = fs.readFileSync(file, "utf-8") + "\n";
return transform ? transform(str, file) : str;
}).join('\n');
}
output = "";

//include require
output += include("thirdparty/browser-require/require.js");

//include modules
output += include(files, function (file, path) {
return "require.define('" + path.replace(/lib\//, "phonegap/").replace(/\.js$/, '') +
"', function (require, module, exports) {\n" + file + "});\n";
});

//include phonegap
output += include('lib/phonegap.js', function (file, path) {
return "require.define('phonegap'" +
", function (require, module, exports) {\n" + file + "});\n";
});

fs.writeFileSync(__dirname + "/pkg/phonegap.js", output);

util.puts(fs.readFileSync("build/dalek", "utf-8"));
});
Submodule uglify-js added at 4f9773
@@ -0,0 +1,10 @@
<html>
<head>
<script type="text/javascript" src="../pkg/phonegap.js"></script>
</head>
<body>
<div>
So this file is just something to include phonegap.js and play with it. I know right! #EPIC
</div>
</body>
</html>
Submodule browser-require added at 0f1c1f

0 comments on commit fafcf2f

Please sign in to comment.