2011-08-14 21:35:36 +00:00
|
|
|
var fs = require('fs'),
|
2011-11-28 04:55:36 +00:00
|
|
|
exec = require('child_process').exec;
|
2011-08-14 21:35:36 +00:00
|
|
|
|
2012-07-19 11:34:32 +00:00
|
|
|
var buildArgs = process.argv.slice(2),
|
2013-10-12 12:43:35 +00:00
|
|
|
buildArgsAsObject = { },
|
|
|
|
|
rootPath = process.cwd(),
|
|
|
|
|
distributionPath = 'dist/';
|
2011-08-14 21:35:36 +00:00
|
|
|
|
2012-07-19 11:34:32 +00:00
|
|
|
buildArgs.forEach(function(arg) {
|
|
|
|
|
var key = arg.split('=')[0],
|
|
|
|
|
value = arg.split('=')[1];
|
|
|
|
|
|
|
|
|
|
buildArgsAsObject[key] = value;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var modulesToInclude = buildArgsAsObject.modules ? buildArgsAsObject.modules.split(',') : [ ];
|
|
|
|
|
var modulesToExclude = buildArgsAsObject.exclude ? buildArgsAsObject.exclude.split(',') : [ ];
|
|
|
|
|
|
2012-10-17 09:03:17 +00:00
|
|
|
var minifier = buildArgsAsObject.minifier || 'uglifyjs';
|
2011-11-28 04:55:36 +00:00
|
|
|
var mininfierCmd;
|
|
|
|
|
|
2013-09-03 18:15:12 +00:00
|
|
|
var noStrict = 'no-strict' in buildArgsAsObject;
|
|
|
|
|
var noSVGExport = 'no-svg-export' in buildArgsAsObject;
|
|
|
|
|
var noES5Compat = 'no-es5-compat' in buildArgsAsObject;
|
|
|
|
|
var requirejs = 'requirejs' in buildArgsAsObject ? 'requirejs' : false;
|
2013-10-12 12:43:35 +00:00
|
|
|
var sourceMap = 'sourcemap' in buildArgsAsObject;
|
2013-09-03 18:15:12 +00:00
|
|
|
|
|
|
|
|
// set amdLib var to encourage later support of other AMD systems
|
|
|
|
|
var amdLib = requirejs;
|
|
|
|
|
|
|
|
|
|
// if we want requirejs AMD support, use uglify
|
2013-09-03 19:23:35 +00:00
|
|
|
var amdUglifyFlags = '';
|
2013-09-03 18:15:12 +00:00
|
|
|
if (amdLib === 'requirejs' && minifier !== 'uglifyjs') {
|
|
|
|
|
console.log('[notice]: require.js support requires uglifyjs as minifier; changed minifier to uglifyjs.');
|
|
|
|
|
minifier = 'uglifyjs';
|
2013-09-03 19:23:35 +00:00
|
|
|
amdUglifyFlags = " -r 'require,exports,window,fabric' -e window:window,undefined ";
|
2013-09-03 18:15:12 +00:00
|
|
|
}
|
|
|
|
|
|
2013-10-12 12:43:35 +00:00
|
|
|
// if we want sourceMap support, uglify or google closure compiler are supported
|
|
|
|
|
var sourceMapFlags = '';
|
|
|
|
|
if (sourceMap) {
|
|
|
|
|
if (minifier !== 'uglifyjs' && minifier !== 'closure') {
|
|
|
|
|
console.log('[notice]: sourceMap support requires uglifyjs or google closure compiler as minifier; changed minifier to uglifyjs.');
|
|
|
|
|
minifier = 'uglifyjs';
|
|
|
|
|
}
|
|
|
|
|
sourceMapFlags = minifier === 'uglifyjs' ? ' --source-map all.min.js.map' : ' --create_source_map all.min.js.map --source_map_format=V3';
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-28 04:55:36 +00:00
|
|
|
if (minifier === 'yui') {
|
2013-10-12 12:43:35 +00:00
|
|
|
mininfierCmd = 'java -jar ' + rootPath + '/lib/yuicompressor-2.4.6.jar all.js -o all.min.js';
|
2011-11-28 04:55:36 +00:00
|
|
|
}
|
|
|
|
|
else if (minifier === 'closure') {
|
2013-10-12 12:43:35 +00:00
|
|
|
mininfierCmd = 'java -jar ' + rootPath + '/lib/google_closure_compiler.jar --js all.js --js_output_file all.min.js' + sourceMapFlags;
|
2011-11-28 04:55:36 +00:00
|
|
|
}
|
2012-10-17 09:03:17 +00:00
|
|
|
else if (minifier === 'uglifyjs') {
|
2013-10-12 12:43:35 +00:00
|
|
|
mininfierCmd = 'uglifyjs ' + amdUglifyFlags + ' --output all.min.js all.js' + sourceMapFlags;
|
2012-10-17 09:03:17 +00:00
|
|
|
}
|
2011-11-28 04:55:36 +00:00
|
|
|
|
2013-05-28 23:05:50 +00:00
|
|
|
var buildSh = 'build-sh' in buildArgsAsObject;
|
|
|
|
|
var buildMinified = 'build-minified' in buildArgsAsObject;
|
|
|
|
|
|
|
|
|
|
var includeAllModules = (modulesToInclude.length === 1 && modulesToInclude[0] === 'ALL') || buildMinified;
|
|
|
|
|
|
2013-05-30 19:55:26 +00:00
|
|
|
var noSVGImport = (modulesToInclude.indexOf('parser') === -1 && !includeAllModules) || modulesToExclude.indexOf('parser') > -1;
|
|
|
|
|
|
2012-07-19 11:34:32 +00:00
|
|
|
var distFileContents =
|
|
|
|
|
'/* build: `node build.js modules=' +
|
|
|
|
|
modulesToInclude.join(',') +
|
|
|
|
|
(modulesToExclude.length ? (' exclude=' + modulesToExclude.join(',')) : '') +
|
|
|
|
|
(noStrict ? ' no-strict' : '') +
|
2013-05-09 18:19:06 +00:00
|
|
|
(noSVGExport ? ' no-svg-export' : '') +
|
2013-05-14 16:34:45 +00:00
|
|
|
(noES5Compat ? ' no-es5-compat' : '') +
|
2013-09-03 18:15:12 +00:00
|
|
|
(requirejs ? ' requirejs' : '') +
|
2013-10-12 12:43:35 +00:00
|
|
|
(sourceMap ? ' sourcemap' : '') +
|
|
|
|
|
' minifier=' + minifier +
|
2013-05-28 23:05:50 +00:00
|
|
|
'` */';
|
2011-08-14 21:35:36 +00:00
|
|
|
|
|
|
|
|
function appendFileContents(fileNames, callback) {
|
2012-05-13 14:47:45 +00:00
|
|
|
|
2011-08-14 21:35:36 +00:00
|
|
|
(function readNextFile() {
|
2012-05-13 14:47:45 +00:00
|
|
|
|
2011-08-14 21:35:36 +00:00
|
|
|
if (fileNames.length <= 0) {
|
|
|
|
|
return callback();
|
|
|
|
|
}
|
2012-05-13 14:47:45 +00:00
|
|
|
|
2011-08-14 21:35:36 +00:00
|
|
|
var fileName = fileNames.shift();
|
2012-05-13 14:47:45 +00:00
|
|
|
|
2011-08-14 21:35:36 +00:00
|
|
|
if (!fileName) {
|
|
|
|
|
return readNextFile();
|
|
|
|
|
}
|
2012-05-13 14:47:45 +00:00
|
|
|
|
2011-08-14 21:35:36 +00:00
|
|
|
fs.readFile(__dirname + '/' + fileName, function (err, data) {
|
|
|
|
|
if (err) throw err;
|
2013-05-09 18:19:06 +00:00
|
|
|
var strData = String(data);
|
2012-07-19 11:34:32 +00:00
|
|
|
if (noStrict) {
|
2013-05-09 18:19:06 +00:00
|
|
|
strData = strData.replace(/"use strict";?\n?/, '');
|
2012-07-19 11:34:32 +00:00
|
|
|
}
|
2013-05-09 18:19:06 +00:00
|
|
|
if (noSVGExport) {
|
2013-05-30 19:55:26 +00:00
|
|
|
strData = strData.replace(/\/\* _TO_SVG_START_ \*\/[\s\S]*?\/\* _TO_SVG_END_ \*\//g, '');
|
2013-05-09 18:19:06 +00:00
|
|
|
}
|
2013-05-14 16:34:45 +00:00
|
|
|
if (noES5Compat) {
|
2013-05-30 19:55:26 +00:00
|
|
|
strData = strData.replace(/\/\* _ES5_COMPAT_START_ \*\/[\s\S]*?\/\* _ES5_COMPAT_END_ \*\//g, '');
|
|
|
|
|
}
|
|
|
|
|
if (noSVGImport) {
|
|
|
|
|
strData = strData.replace(/\/\* _FROM_SVG_START_ \*\/[\s\S]*?\/\* _FROM_SVG_END_ \*\//g, '');
|
2013-05-14 16:34:45 +00:00
|
|
|
}
|
2013-05-28 23:05:50 +00:00
|
|
|
distFileContents += ('\n' + strData + '\n');
|
2011-08-14 21:35:36 +00:00
|
|
|
readNextFile();
|
|
|
|
|
});
|
2012-05-13 14:47:45 +00:00
|
|
|
|
2011-08-14 21:35:36 +00:00
|
|
|
})();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function ifSpecifiedInclude(moduleName, fileName) {
|
2012-07-19 11:34:32 +00:00
|
|
|
var isInIncludedList = modulesToInclude.indexOf(moduleName) > -1;
|
|
|
|
|
var isInExcludedList = modulesToExclude.indexOf(moduleName) > -1;
|
|
|
|
|
|
|
|
|
|
// excluded list takes precedence over modules=ALL
|
|
|
|
|
return ((isInIncludedList || includeAllModules) && !isInExcludedList) ? fileName : '';
|
2011-08-14 21:35:36 +00:00
|
|
|
}
|
|
|
|
|
|
2012-07-24 09:21:32 +00:00
|
|
|
function ifSpecifiedDependencyInclude(included, excluded, fileName) {
|
|
|
|
|
return (
|
|
|
|
|
(
|
|
|
|
|
(modulesToInclude.indexOf(included) > -1 || includeAllModules) &&
|
|
|
|
|
(modulesToExclude.indexOf(excluded) == -1))
|
|
|
|
|
? fileName
|
|
|
|
|
: ''
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-03 18:15:12 +00:00
|
|
|
function ifSpecifiedAMDInclude(amdLib) {
|
|
|
|
|
var supportedLibraries = ['requirejs'];
|
|
|
|
|
if (supportedLibraries.indexOf(amdLib) > -1) {
|
|
|
|
|
return 'src/amd/' + amdLib + '.js';
|
|
|
|
|
}
|
|
|
|
|
return '';
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-14 21:35:36 +00:00
|
|
|
var filesToInclude = [
|
|
|
|
|
'HEADER.js',
|
2012-05-13 14:47:45 +00:00
|
|
|
|
2012-07-24 09:21:32 +00:00
|
|
|
ifSpecifiedDependencyInclude('text', 'cufon', 'lib/cufon.js'),
|
|
|
|
|
ifSpecifiedDependencyInclude('serialization', 'json', 'lib/json2.js'),
|
2013-05-31 10:46:46 +00:00
|
|
|
ifSpecifiedInclude('gestures', 'lib/event.js'),
|
2013-01-10 17:23:23 +00:00
|
|
|
|
2013-05-18 14:43:49 +00:00
|
|
|
'src/mixins/observable.mixin.js',
|
|
|
|
|
'src/mixins/collection.mixin.js',
|
2012-05-13 14:47:45 +00:00
|
|
|
|
2011-08-14 21:35:36 +00:00
|
|
|
'src/util/misc.js',
|
2013-11-16 13:59:34 +00:00
|
|
|
'src/util/arc.js',
|
2011-08-14 21:35:36 +00:00
|
|
|
'src/util/lang_array.js',
|
|
|
|
|
'src/util/lang_object.js',
|
|
|
|
|
'src/util/lang_string.js',
|
|
|
|
|
'src/util/lang_function.js',
|
|
|
|
|
'src/util/lang_class.js',
|
|
|
|
|
'src/util/dom_event.js',
|
|
|
|
|
'src/util/dom_style.js',
|
|
|
|
|
'src/util/dom_misc.js',
|
|
|
|
|
'src/util/dom_request.js',
|
2012-05-13 14:47:45 +00:00
|
|
|
|
2013-11-10 14:15:31 +00:00
|
|
|
'src/log.js',
|
|
|
|
|
|
2013-09-28 21:46:14 +00:00
|
|
|
ifSpecifiedInclude('animation', 'src/util/animate.js'),
|
|
|
|
|
//'src/util/animate.js',
|
2012-04-26 02:58:03 +00:00
|
|
|
ifSpecifiedInclude('easing', 'src/util/anim_ease.js'),
|
|
|
|
|
|
2011-08-14 21:35:36 +00:00
|
|
|
ifSpecifiedInclude('parser', 'src/parser.js'),
|
2013-11-04 16:12:05 +00:00
|
|
|
ifSpecifiedInclude('parser', 'src/elements_parser.js'),
|
2012-05-13 14:47:45 +00:00
|
|
|
|
2013-05-30 19:55:26 +00:00
|
|
|
'src/point.class.js',
|
2011-08-14 21:35:36 +00:00
|
|
|
'src/intersection.class.js',
|
|
|
|
|
'src/color.class.js',
|
2012-05-13 14:47:45 +00:00
|
|
|
|
2013-07-04 12:17:41 +00:00
|
|
|
ifSpecifiedInclude('gradient', 'src/gradient.class.js'),
|
|
|
|
|
ifSpecifiedInclude('pattern', 'src/pattern.class.js'),
|
|
|
|
|
ifSpecifiedInclude('shadow', 'src/shadow.class.js'),
|
|
|
|
|
|
2011-11-28 04:55:36 +00:00
|
|
|
'src/static_canvas.class.js',
|
2012-11-24 19:12:33 +00:00
|
|
|
|
2013-05-18 14:43:49 +00:00
|
|
|
ifSpecifiedInclude('freedrawing', 'src/brushes/base_brush.class.js'),
|
2013-01-20 16:28:06 +00:00
|
|
|
|
2013-05-18 14:43:49 +00:00
|
|
|
ifSpecifiedInclude('freedrawing', 'src/brushes/pencil_brush.class.js'),
|
|
|
|
|
ifSpecifiedInclude('freedrawing', 'src/brushes/circle_brush.class.js'),
|
|
|
|
|
ifSpecifiedInclude('freedrawing', 'src/brushes/spray_brush.class.js'),
|
|
|
|
|
ifSpecifiedInclude('freedrawing', 'src/brushes/pattern_brush.class.js'),
|
2012-11-29 19:40:26 +00:00
|
|
|
|
2011-11-28 04:55:36 +00:00
|
|
|
ifSpecifiedInclude('interaction', 'src/canvas.class.js'),
|
2013-05-18 14:43:49 +00:00
|
|
|
ifSpecifiedInclude('interaction', 'src/mixins/canvas_events.mixin.js'),
|
2013-11-11 15:07:51 +00:00
|
|
|
ifSpecifiedInclude('interaction', 'src/mixins/canvas_grouping.mixin.js'),
|
2012-05-13 14:47:45 +00:00
|
|
|
|
2013-06-06 10:31:32 +00:00
|
|
|
'src/mixins/canvas_dataurl_exporter.mixin.js',
|
2012-05-13 14:47:45 +00:00
|
|
|
|
2013-05-18 14:43:49 +00:00
|
|
|
ifSpecifiedInclude('serialization', 'src/mixins/canvas_serialization.mixin.js'),
|
|
|
|
|
ifSpecifiedInclude('gestures', 'src/mixins/canvas_gestures.mixin.js'),
|
2012-05-13 14:47:45 +00:00
|
|
|
|
2013-05-30 19:55:26 +00:00
|
|
|
'src/shapes/object.class.js',
|
2013-05-18 14:43:49 +00:00
|
|
|
'src/mixins/object_origin.mixin.js',
|
|
|
|
|
'src/mixins/object_geometry.mixin.js',
|
2013-05-30 19:55:26 +00:00
|
|
|
'src/mixins/stateful.mixin.js',
|
2013-01-20 16:30:34 +00:00
|
|
|
|
2013-05-18 14:43:49 +00:00
|
|
|
ifSpecifiedInclude('interaction', 'src/mixins/object_interactivity.mixin.js'),
|
2013-01-20 16:30:34 +00:00
|
|
|
|
2013-09-28 21:46:14 +00:00
|
|
|
ifSpecifiedInclude('animation', 'src/mixins/animation.mixin.js'),
|
|
|
|
|
//'src/mixins/animation.mixin.js',
|
2013-07-28 13:42:08 +00:00
|
|
|
|
2013-05-30 19:55:26 +00:00
|
|
|
'src/shapes/line.class.js',
|
|
|
|
|
'src/shapes/circle.class.js',
|
|
|
|
|
'src/shapes/triangle.class.js',
|
|
|
|
|
'src/shapes/ellipse.class.js',
|
|
|
|
|
'src/shapes/rect.class.js',
|
|
|
|
|
'src/shapes/polyline.class.js',
|
|
|
|
|
'src/shapes/polygon.class.js',
|
|
|
|
|
'src/shapes/path.class.js',
|
|
|
|
|
'src/shapes/path_group.class.js',
|
|
|
|
|
'src/shapes/group.class.js',
|
|
|
|
|
'src/shapes/image.class.js',
|
2012-05-13 14:47:45 +00:00
|
|
|
|
2013-05-18 14:43:49 +00:00
|
|
|
ifSpecifiedInclude('object_straightening', 'src/mixins/object_straightening.mixin.js'),
|
2012-05-13 14:47:45 +00:00
|
|
|
|
2013-08-13 12:06:33 +00:00
|
|
|
ifSpecifiedInclude('image_filters', 'src/filters/base_filter.class.js'),
|
2013-05-26 13:42:29 +00:00
|
|
|
ifSpecifiedInclude('image_filters', 'src/filters/brightness_filter.class.js'),
|
|
|
|
|
ifSpecifiedInclude('image_filters', 'src/filters/convolute_filter.class.js'),
|
|
|
|
|
ifSpecifiedInclude('image_filters', 'src/filters/gradienttransparency_filter.class.js'),
|
|
|
|
|
ifSpecifiedInclude('image_filters', 'src/filters/grayscale_filter.class.js'),
|
|
|
|
|
ifSpecifiedInclude('image_filters', 'src/filters/invert_filter.class.js'),
|
2013-08-15 14:09:16 +00:00
|
|
|
ifSpecifiedInclude('image_filters', 'src/filters/mask_filter.class.js'),
|
2013-05-26 13:42:29 +00:00
|
|
|
ifSpecifiedInclude('image_filters', 'src/filters/noise_filter.class.js'),
|
|
|
|
|
ifSpecifiedInclude('image_filters', 'src/filters/pixelate_filter.class.js'),
|
|
|
|
|
ifSpecifiedInclude('image_filters', 'src/filters/removewhite_filter.class.js'),
|
|
|
|
|
ifSpecifiedInclude('image_filters', 'src/filters/sepia_filter.class.js'),
|
|
|
|
|
ifSpecifiedInclude('image_filters', 'src/filters/sepia2_filter.class.js'),
|
|
|
|
|
ifSpecifiedInclude('image_filters', 'src/filters/tint_filter.class.js'),
|
2012-05-13 14:47:45 +00:00
|
|
|
|
2013-05-30 19:59:58 +00:00
|
|
|
ifSpecifiedInclude('text', 'src/shapes/text.class.js'),
|
2013-06-06 10:31:32 +00:00
|
|
|
ifSpecifiedInclude('cufon', 'src/shapes/text.cufon.js'),
|
2013-10-27 13:05:35 +00:00
|
|
|
|
2013-10-25 08:31:13 +00:00
|
|
|
ifSpecifiedInclude('itext', 'src/shapes/itext.class.js'),
|
2013-10-30 13:55:02 +00:00
|
|
|
ifSpecifiedInclude('itext', 'src/mixins/itext_behavior.mixin.js'),
|
2013-11-19 11:56:12 +00:00
|
|
|
ifSpecifiedInclude('itext', 'src/mixins/itext_click_behavior.mixin.js'),
|
|
|
|
|
ifSpecifiedInclude('itext', 'src/mixins/itext_key_behavior.mixin.js'),
|
2012-05-13 14:47:45 +00:00
|
|
|
|
2013-09-03 18:15:12 +00:00
|
|
|
ifSpecifiedInclude('node', 'src/node.js'),
|
|
|
|
|
|
|
|
|
|
ifSpecifiedAMDInclude(amdLib)
|
2011-08-14 21:35:36 +00:00
|
|
|
];
|
|
|
|
|
|
2013-05-28 23:05:50 +00:00
|
|
|
if (buildMinified) {
|
|
|
|
|
for (var i = 0; i < filesToInclude.length; i++) {
|
|
|
|
|
if (!filesToInclude[i]) continue;
|
2013-05-30 20:09:55 +00:00
|
|
|
var fileNameWithoutSlashes = filesToInclude[i].replace(/\//g, '^');
|
2013-09-03 18:15:12 +00:00
|
|
|
exec('uglifyjs -nc ' + amdUglifyFlags + filesToInclude[i] + ' > tmp/' + fileNameWithoutSlashes);
|
2013-05-28 23:05:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (buildSh) {
|
|
|
|
|
|
|
|
|
|
var filesStr = filesToInclude.join(' ');
|
|
|
|
|
var isBasicBuild = modulesToInclude.length === 0;
|
|
|
|
|
|
|
|
|
|
var minFilesStr = filesToInclude
|
|
|
|
|
.filter(function(f) { return f !== '' })
|
|
|
|
|
.map(function(fileName) {
|
|
|
|
|
return 'tmp/' + fileName.replace(/\//g, '^');
|
|
|
|
|
})
|
|
|
|
|
.join(' ');
|
|
|
|
|
|
|
|
|
|
var fileName = isBasicBuild ? 'fabric' : modulesToInclude.join(',');
|
|
|
|
|
|
|
|
|
|
var escapedHeader = distFileContents.replace(/`/g, '\\`');
|
|
|
|
|
var path = '../fabricjs.com/build/files/' + fileName + '.js';
|
|
|
|
|
fs.appendFile('build.sh',
|
|
|
|
|
'echo "' + escapedHeader + '" > ' + path + ' && cat ' +
|
|
|
|
|
filesStr + ' >> ' + path + '\n');
|
|
|
|
|
|
|
|
|
|
path = '../fabricjs.com/build/files/' + fileName + '.min.js';
|
|
|
|
|
fs.appendFile('build.sh',
|
|
|
|
|
'echo "' + escapedHeader + '" > ' + path + ' && cat ' +
|
|
|
|
|
minFilesStr + ' >> ' + path + '\n')
|
|
|
|
|
}
|
|
|
|
|
else {
|
2013-10-12 12:43:35 +00:00
|
|
|
// Change the current working directory
|
|
|
|
|
process.chdir(distributionPath);
|
|
|
|
|
|
2013-05-28 23:05:50 +00:00
|
|
|
appendFileContents(filesToInclude, function() {
|
2013-10-12 12:43:35 +00:00
|
|
|
fs.writeFile('all.js', distFileContents, function (err) {
|
2013-05-28 23:05:50 +00:00
|
|
|
if (err) {
|
|
|
|
|
console.log(err);
|
|
|
|
|
throw err;
|
2011-11-28 04:55:36 +00:00
|
|
|
}
|
2012-05-13 14:47:45 +00:00
|
|
|
|
2013-09-03 18:15:12 +00:00
|
|
|
// add js wrapping in AMD closure for requirejs if necessary
|
|
|
|
|
if (amdLib !== false) {
|
2013-10-12 12:43:35 +00:00
|
|
|
exec('uglifyjs all.js ' + amdUglifyFlags + ' -b --output all.js');
|
2013-09-03 18:15:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (amdLib !== false) {
|
2013-10-12 12:43:35 +00:00
|
|
|
console.log('Built distribution to ' + distributionPath + 'all.js (' + amdLib + '-compatible)');
|
2013-09-03 18:15:12 +00:00
|
|
|
} else {
|
2013-10-12 12:43:35 +00:00
|
|
|
console.log('Built distribution to ' + distributionPath + 'all.js');
|
2013-09-03 18:15:12 +00:00
|
|
|
}
|
2013-05-28 23:05:50 +00:00
|
|
|
|
|
|
|
|
exec(mininfierCmd, function (error, output) {
|
2013-06-19 09:53:58 +00:00
|
|
|
if (error) {
|
|
|
|
|
console.error('Minification failed using', minifier, 'with', mininfierCmd);
|
|
|
|
|
process.exit(1);
|
2013-05-28 23:05:50 +00:00
|
|
|
}
|
2013-10-12 12:43:35 +00:00
|
|
|
console.log('Minified using', minifier, 'to ' + distributionPath + 'all.min.js');
|
2013-06-19 09:53:58 +00:00
|
|
|
|
2013-10-12 12:43:35 +00:00
|
|
|
if (sourceMapFlags) {
|
|
|
|
|
console.log('Built sourceMap to ' + distributionPath + 'all.min.js.map');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
exec('gzip -c all.min.js > all.min.js.gz', function (error, output) {
|
|
|
|
|
console.log('Gzipped to ' + distributionPath + 'all.min.js.gz');
|
2011-11-28 04:55:36 +00:00
|
|
|
});
|
|
|
|
|
});
|
2013-09-03 18:15:12 +00:00
|
|
|
|
2013-10-12 12:43:35 +00:00
|
|
|
// Always build requirejs AMD module in all.require.js
|
2013-09-03 18:15:12 +00:00
|
|
|
// add necessary requirejs footer code to filesToInclude if we haven't before
|
|
|
|
|
if (amdLib === false) {
|
|
|
|
|
amdLib = "requirejs";
|
|
|
|
|
filesToInclude[filesToInclude.length] = ifSpecifiedAMDInclude(amdLib);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
appendFileContents(filesToInclude, function() {
|
2013-10-12 12:43:35 +00:00
|
|
|
fs.writeFile('all.require.js', distFileContents, function (err) {
|
2013-09-03 18:15:12 +00:00
|
|
|
if (err) {
|
|
|
|
|
console.log(err);
|
|
|
|
|
throw err;
|
|
|
|
|
}
|
2013-10-12 12:43:35 +00:00
|
|
|
exec('uglifyjs all.require.js ' + amdUglifyFlags + ' -b --output all.require.js');
|
|
|
|
|
console.log('Built distribution to ' + distributionPath + 'all.require.js (requirejs-compatible)');
|
2013-09-03 18:15:12 +00:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2011-11-28 04:55:36 +00:00
|
|
|
});
|
2011-08-14 21:35:36 +00:00
|
|
|
});
|
2013-05-28 23:05:50 +00:00
|
|
|
}
|