mirror of
https://github.com/sartography/bpmn-js.git
synced 2025-01-11 17:44:12 +00:00
parent
9272547af2
commit
ae49bb719b
@ -32,10 +32,9 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"brfs": "^1.2.0",
|
"brfs": "^1.2.0",
|
||||||
"browserify": "^8.1.0",
|
"browserify": "^8.1.0",
|
||||||
|
"browserify-derequire": "^0.9.1",
|
||||||
"bundle-collapser": "^1.1.1",
|
"bundle-collapser": "^1.1.1",
|
||||||
"derequire": "^1.2.0",
|
|
||||||
"diagram-js": "^0.8.0",
|
"diagram-js": "^0.8.0",
|
||||||
"exposify": "https://github.com/Nikku/exposify/archive/v0.2.0-transform-arguments-0.tar.gz",
|
|
||||||
"grunt": "^0.4.4",
|
"grunt": "^0.4.4",
|
||||||
"grunt-contrib-copy": "^0.7.0",
|
"grunt-contrib-copy": "^0.7.0",
|
||||||
"grunt-contrib-jshint": "^0.7.2",
|
"grunt-contrib-jshint": "^0.7.2",
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
var browserify = require('browserify'),
|
var browserify = require('browserify'),
|
||||||
derequire = require('derequire'),
|
derequire = require('browserify-derequire'),
|
||||||
UglifyJS = require('uglify-js'),
|
UglifyJS = require('uglify-js'),
|
||||||
exposify = require('exposify'),
|
|
||||||
collapse = require('bundle-collapser/plugin'),
|
collapse = require('bundle-collapser/plugin'),
|
||||||
concat = require('source-map-concat'),
|
concat = require('source-map-concat'),
|
||||||
fs = require('fs'),
|
fs = require('fs'),
|
||||||
@ -11,15 +12,6 @@ var browserify = require('browserify'),
|
|||||||
var BANNER = fs.readFileSync(__dirname + '/banner.txt', 'utf8'),
|
var BANNER = fs.readFileSync(__dirname + '/banner.txt', 'utf8'),
|
||||||
BANNER_MIN = fs.readFileSync(__dirname + '/banner-min.txt', 'utf8');
|
BANNER_MIN = fs.readFileSync(__dirname + '/banner-min.txt', 'utf8');
|
||||||
|
|
||||||
var EXTERNALS = {
|
|
||||||
sax: 'sax',
|
|
||||||
snapsvg: 'Snap',
|
|
||||||
lodash: '_',
|
|
||||||
hammerjs: 'Hammer',
|
|
||||||
jquery: '$',
|
|
||||||
'jquery-mousewheel': '$'
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
function extractSourceMap(content) {
|
function extractSourceMap(content) {
|
||||||
|
|
||||||
@ -64,6 +56,24 @@ function uglify(bundle, preamble) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function Timer() {
|
||||||
|
this.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer.prototype.done = function(message) {
|
||||||
|
console.log(message, '[' + (this.now() - this.start) + 'ms]');
|
||||||
|
this.reset();
|
||||||
|
};
|
||||||
|
|
||||||
|
Timer.prototype.reset = function() {
|
||||||
|
this.start = this.now();
|
||||||
|
};
|
||||||
|
|
||||||
|
Timer.prototype.now = function() {
|
||||||
|
return new Date().getTime();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
module.exports = function(grunt) {
|
module.exports = function(grunt) {
|
||||||
|
|
||||||
grunt.registerMultiTask('bundle', function(target) {
|
grunt.registerMultiTask('bundle', function(target) {
|
||||||
@ -78,37 +88,43 @@ module.exports = function(grunt) {
|
|||||||
var done = this.async();
|
var done = this.async();
|
||||||
|
|
||||||
var browserifyOptions = {
|
var browserifyOptions = {
|
||||||
builtins: false,
|
|
||||||
standalone: 'BpmnJS',
|
standalone: 'BpmnJS',
|
||||||
detectGlobals: false,
|
debug: true,
|
||||||
insertGlobalVars: [],
|
builtins: false,
|
||||||
debug: true
|
insertGlobalVars: {
|
||||||
|
process: function () {
|
||||||
|
return 'undefined';
|
||||||
|
},
|
||||||
|
Buffer: function () {
|
||||||
|
return 'undefined';
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var exposifyOptions = {
|
var timer = new Timer();
|
||||||
global: true,
|
|
||||||
expose: EXTERNALS
|
|
||||||
};
|
|
||||||
|
|
||||||
var targetFileBase = path.join(dest, variant);
|
var targetFileBase = path.join(dest, variant);
|
||||||
|
|
||||||
var banner = grunt.template.process(BANNER, grunt.config.get()),
|
var banner = grunt.template.process(BANNER, grunt.config.get()),
|
||||||
bannerMin = grunt.template.process(BANNER_MIN, grunt.config.get());
|
bannerMin = grunt.template.process(BANNER_MIN, grunt.config.get());
|
||||||
|
|
||||||
|
|
||||||
browserify(browserifyOptions)
|
browserify(browserifyOptions)
|
||||||
.transform(exposify, exposifyOptions)
|
.plugin(derequire)
|
||||||
.plugin(collapse)
|
.plugin(collapse)
|
||||||
.add(src)
|
.add(src)
|
||||||
.bundle(function(err, result) {
|
.bundle(function(err, result) {
|
||||||
|
|
||||||
|
timer.done('bundled');
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
return done(err);
|
return done(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
var bundled, minified;
|
var bundled, minified;
|
||||||
|
|
||||||
bundled = extractSourceMap(derequire(result.toString('utf8')));
|
bundled = extractSourceMap(result.toString('utf8'));
|
||||||
|
|
||||||
|
timer.done('extracted source map');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
minified = uglify(bundled, bannerMin);
|
minified = uglify(bundled, bannerMin);
|
||||||
@ -116,6 +132,8 @@ module.exports = function(grunt) {
|
|||||||
return done(e);
|
return done(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
timer.done('minified');
|
||||||
|
|
||||||
var bannerBundled;
|
var bannerBundled;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -128,11 +146,15 @@ module.exports = function(grunt) {
|
|||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
timer.done('added banner');
|
||||||
|
|
||||||
grunt.file.write(targetFileBase + '.js', bannerBundled.code, 'utf8');
|
grunt.file.write(targetFileBase + '.js', bannerBundled.code, 'utf8');
|
||||||
grunt.file.write(targetFileBase + '.js.map', bannerBundled.map, 'utf8');
|
grunt.file.write(targetFileBase + '.js.map', bannerBundled.map, 'utf8');
|
||||||
|
|
||||||
grunt.file.write(targetFileBase + '.min.js', minified.code, 'utf8');
|
grunt.file.write(targetFileBase + '.min.js', minified.code, 'utf8');
|
||||||
|
|
||||||
|
timer.done('all saved');
|
||||||
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user