JCPalmer Posted March 24, 2015 Share Posted March 24, 2015 I have this problem: The source code for my 3D font is too big for the over the web Uglify page I was using. I wanted to save prebuilt fonts when I post Dialog to the extensions repository. This means most will not have to run Blender / Tower of Babel. I have already reduced the # of letters in both 2D & 3D fonts down to 96, by breaking them into 2 modules: Font3D & Font3D_EXT (same pattern for 2D). You set the version using the ENGLISH_STD var before generation in the .blend:# delete any characters that you are sure NOT to use# for english set file / module name ending id 2D or 3D# for european chars end in 2D_EXT, 3D_EXTENGLISH_STD = Trueif ENGLISH_STD: VOWELS_U = 'AEIOU' VOWELS_L = 'aeiou' CONS_U = 'BCDFGHJKLMNPQRSTVWXYZ' CONS_L = 'bcdfghjklmnpqrstvwxyz' NUMBERS = '0123456789' SPECIALS = ',.!?=+-*&^%$#@`~;)[]{}\'"_<>/|\\'else: VOWELS_U = 'ÁÀÂÄÉÈÊËÎÏÔÖØÙÛÜÆ' VOWELS_L = 'áàâäéèêëîïôöøùûüæ' CONS_U = 'ÇÑ' CONS_L = 'çñß' NUMBERS = '' SPECIALS = ''Also means, unless you need these letters there is no need to load the _EXT.js. The Gulp process already has a uglify. Could there be a way added or documentation on how to Uglify your own files? I am sort of hanging on for dear life in regard to Node. Thanks, Jeff Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted March 24, 2015 Author Share Posted March 24, 2015 Well, I had to my Gulp actually working again. The typescript version change broke me. Did not need that part for this, but need a working build. Playing on my own, I made a file in the Gulp dir, called makeUgly.js. The site I based it on is the first line comment. I added a surrounding function, args// based on: http://davidwalsh.name/compress-uglifyvar UglifyJS = require('uglify-js');var fs = require('fs');var makeUgly = function(path, fileIn){ if (path.lastIndexOf('/') + 1 !== path.length) { path += '/'; } var fileOut = fileIn.replace('.js', '.min.js'); var result = UglifyJS.minify(path + fileIn, { mangle: true, compress: { sequences: true, dead_code: true, conditionals: true, booleans: true, unused: true, if_return: true, join_vars: true, drop_console: true } }); fs.writeFileSync(path + fileOut, result.code);};When I looked to see how start it based on what gulpfile.js was, I realized gulp had its own uglify. I have now edited gulpfile.js, aading this:gulp.task('makeUgly' ,function(path, fileIn) { if (path.lastIndexOf('/') + 1 !== path.length) { path += '/'; } return gulp.src([path + fileIn]) .pipe(rename({suffix: '.min'})) .pipe(uglify()) .pipe(gulp.dest(path))});Still trying determine how call this and specifying arguments. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted March 24, 2015 Share Posted March 24, 2015 which one is the best relatively to size? Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted March 25, 2015 Author Share Posted March 25, 2015 Do not know. Gulp does not have args???? Need a fourth party addon, https://www.npmjs.com/package/gulp-param. The uglify-js way also needs to be installed. I am not confident enough to modify / butcher my system. I need this to build babylonJS. These 'Node people' only ever tell you how to install something, but never un-install. Guess 3D font users will just have to do it themselves for now. I also do not know if TOB generated source code should vary that much by the compressor, in terms of output size. There is very little branching. I do all that in python. Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted April 8, 2015 Author Share Posted April 8, 2015 I have just revisited this. I only got the Gulp-uglify with arguments to work. Modified gulpfile.js: - changed line 1 to: var gulp = require('gulp-param')(require('gulp'), process.argv), - added this task at the bottom:/** * task to uglify a file passed as an argument */gulp.task('makeUgly' ,function(path, fileIn) { if (path.lastIndexOf('/') + 1 !== path.length) { path += '/'; } return gulp.src([path + fileIn]) .pipe(rename({suffix: '.min'})) .pipe(uglify()) .pipe(gulp.dest(path))});I also typed this in on the command line : (sudo) npm install gulp-param From command line entered: gulp makeUgly --path /js-dev/Extensions/Dialog/fonts --fileIn Font3D.jsIt worked. Compression was not great since it was mostly numbers specifying vertices, but should load faster being on only 24 lines. Question is can or should this be PR'ed? I need it for 7 JS files in Extensions (morph, POV, dialog, Font2D, Font3D, Font2d_EXT, Font3D_EXT). Could be useful, If you wish to uglify your own game, and it also got too big for the web page based uglifiers. Not sure what you would have to do as far as install to new or existing systems. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted April 8, 2015 Share Posted April 8, 2015 yes sounds good to me for a PR Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.