diff --git a/Gruntfile.js b/Gruntfile.js index 81cff575..4eb85b83 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -42,7 +42,7 @@ module.exports = function(grunt) { sources: 'lib', tests: 'test', dist: 'dist', - samples: 'example' + bowerDist: '../bower-bpmn-js' }, jshint: { @@ -129,7 +129,7 @@ module.exports = function(grunt) { }, bowerViewer: { files: { - '../bower-bpmn-js/bpmn-viewer.js': [ '<%= config.sources %>/lib/Viewer.js' ] + '<%= config.bowerDist %>/bpmn-viewer.js': [ '<%= config.sources %>/lib/Viewer.js' ] }, options: { bundleOptions: { @@ -181,36 +181,18 @@ module.exports = function(grunt) { } }, - copy: { - samples: { - files: [ - // copy sample files - { - expand: true, - cwd: '<%= config.samples %>/', - src: ['**/*.*'], - dest: '<%= config.dist %>/<%= config.samples %>' - } - ] - } - }, - watch: { - samples: { - files: [ '<%= config.samples %>/**/*.*' ], - tasks: [ 'build:samples' ] - }, - jasmine_node: { - files: [ '<%= config.sources %>/**/*.js', '<%= config.tests %>/spec/node/**/*.js' ], - tasks: [ 'jasmine_node' ] - }, - modeler: { + standaloneModeler: { files: [ '<%= config.dist %>/bpmn.js' ], - tasks: [ 'uglify:modeler' ] + tasks: [ 'uglify:standaloneModeler' ] }, - viewer: { + standaloneViewer: { files: [ '<%= config.dist %>/bpmn-viewer.js' ], - tasks: [ 'uglify:viewer' ] + tasks: [ 'uglify:standaloneViewer' ] + }, + bowerViewer: { + files: [ '<%= config.bowerDist %>/bpmn-viewer.js' ], + tasks: [ 'uglify:bowerViewer' ] } }, @@ -224,21 +206,6 @@ module.exports = function(grunt) { } }, - connect: { - options: { - port: 9003, - livereload: 35726, - hostname: 'localhost' - }, - livereload: { - options: { - open: true, - base: [ - '<%= config.dist %>' - ] - } - } - }, uglify: { options: { banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' + @@ -264,12 +231,17 @@ module.exports = function(grunt) { } } }, - modeler: { + bowerViewer: { + files: { + '<%= config.bowerDist %>/bpmn-viewer.min.js': [ '<%= config.bowerDist %>/bpmn-viewer.js' ] + } + }, + standaloneModeler: { files: { '<%= config.dist %>/bpmn.min.js': [ '<%= config.dist %>/bpmn.js' ] } }, - viewer: { + standaloneViewer: { files: { '<%= config.dist %>/bpmn-viewer.min.js': [ '<%= config.dist %>/bpmn-viewer.js' ] } @@ -281,32 +253,42 @@ module.exports = function(grunt) { grunt.registerTask('test', [ 'jasmine_node', 'karma:single' ]); + ///// + // + // the main build task that bundles bpmn-js files + // + // valid executions are + // + // * build -> build:all + // * build:all -> build:lib, build:bower + // * build:lib -> { packages library files as standalone bundle } + // * build:lib -> { packages library files as bower bundle } + // grunt.registerTask('build', function(target, mode) { mode = mode || 'prod'; + if (target === 'bower') { + return grunt.task.run(['browserify:bowerViewer', 'uglify:bowerViewer']); + } + if (target === 'lib') { var tasks = []; if (mode !== 'dev') { - tasks.push('uglify:modeler', 'uglify:viewer'); + tasks.push('uglify:standaloneModeler', 'uglify:standaloneViewer'); } return grunt.task.run(['browserify:standaloneViewer', 'browserify:standaloneModeler'].concat(tasks)); } - if (target === 'samples') { - return grunt.task.run(['copy:samples']); - } - if (!target || target === 'all') { - return grunt.task.run(['build:lib:' + mode, 'build:samples:' + mode]); + return grunt.task.run(['build:lib:' + mode, 'build:bower' ]); } }); grunt.registerTask('auto-build', [ 'browserify:watch', - 'connect:livereload', 'watch' ]); diff --git a/package.json b/package.json index fe984f7a..6375bf89 100644 --- a/package.json +++ b/package.json @@ -33,8 +33,6 @@ "exposify": "https://github.com/Nikku/exposify/archive/v0.2.0-transform-arguments-0.tar.gz", "grunt": "~0.4.4", "grunt-browserify": "~2.1.0", - "grunt-contrib-connect": "~0.6.0", - "grunt-contrib-copy": "~0.5.0", "grunt-contrib-jshint": "~0.7.2", "grunt-contrib-uglify": "~0.4.0", "grunt-contrib-watch": "~0.5.0", @@ -43,13 +41,13 @@ "grunt-karma": "~0.8.0", "grunt-release": "~0.7.0", "jsondiffpatch": "^0.1.7", - "karma": "~0.12.8", + "karma": "^0.12.12", "karma-bro": "~0.2.0", - "karma-chrome-launcher": "~0.1.2", - "karma-firefox-launcher": "~0.1.3", - "karma-ie-launcher": "~0.1.4", + "karma-chrome-launcher": "^0.1.2", + "karma-firefox-launcher": "^0.1.3", + "karma-ie-launcher": "^0.1.4", "karma-jasmine": "https://github.com/Nikku/karma-jasmine/archive/jasmine-v2.0.0-latest-1.tar.gz", - "karma-phantomjs-launcher": "0.1.2", + "karma-phantomjs-launcher": "^0.1.2", "load-grunt-tasks": "~0.3.0", "time-grunt": "~0.3.0" },