Skip to content

Commit

Permalink
Added minified build.
Browse files Browse the repository at this point in the history
  • Loading branch information
loktar00 committed Mar 19, 2012
1 parent 4d8e4d8 commit 96a8df7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
22 changes: 20 additions & 2 deletions build.js
@@ -1,7 +1,8 @@
// settings
var FILE_ENCODING = 'utf-8',
EOL = '\n',
DIST_FILE_PATH = 'build/jest.js';
DIST_FILE_PATH = 'build/jest.js',
MIN_FILE = 'build/jest.min.js';

// setup
var _fs = require('fs');
Expand All @@ -10,10 +11,25 @@ function concat(fileList, distPath) {
var out = fileList.map(function(filePath){
return _fs.readFileSync(filePath, FILE_ENCODING);
});

_fs.writeFileSync(distPath, out.join(EOL), FILE_ENCODING);
console.log(' '+ distPath +' built.');
}

function uglify(srcPath, distPath) {
var
uglyfyJS = require('uglify-js'),
jsp = uglyfyJS.parser,
pro = uglyfyJS.uglify,
ast = jsp.parse( _fs.readFileSync(srcPath, FILE_ENCODING) );

ast = pro.ast_mangle(ast);
ast = pro.ast_squeeze(ast);

_fs.writeFileSync(distPath, pro.gen_code(ast), FILE_ENCODING);
console.log(' '+ distPath +' built.');
}

concat([
'js/jgame/vector.js',
'js/jgame/utilities.js',
Expand All @@ -33,4 +49,6 @@ concat([
'js/jgame/background.js',
'js/jgame/transition.js',
'js/jgame/background.js',
], DIST_FILE_PATH);
], DIST_FILE_PATH);

uglify(DIST_FILE_PATH, MIN_FILE);

0 comments on commit 96a8df7

Please sign in to comment.