diff --git a/package.json b/package.json index e86de761..cca898b1 100644 --- a/package.json +++ b/package.json @@ -7,10 +7,7 @@ "lint": "eslint .", "dev": "npm test -- --auto-watch --no-single-run", "test": "karma start test/config/karma.unit.js", - "clean": "del dist/*", - "build-distro": "node tasks/build-distro.js", - "copy-assets": "node tasks/copy-assets.js", - "distro": "run-s clean copy-assets build-distro", + "distro": "node tasks/build-distro.js", "prepublishOnly": "run-s distro" }, "repository": { @@ -46,6 +43,7 @@ "chai-match": "^1.1.1", "common-shakeify": "^0.4.5", "cpx": "^1.5.0", + "del": "^3.0.0", "del-cli": "^1.1.0", "eslint": "^4.14.0", "eslint-plugin-mocha": "^4.9.0", @@ -61,6 +59,7 @@ "karma-safari-launcher": "^1.0.0", "karma-sinon-chai": "^1.3.2", "karma-spec-reporter": "0.0.31", + "mkdirp": "^0.5.1", "mocha": "^4.0.1", "mocha-test-container-support": "0.2.0", "npm-run-all": "^4.1.2", diff --git a/tasks/build-distro.js b/tasks/build-distro.js index 2c383cb9..ca51a9cf 100644 --- a/tasks/build-distro.js +++ b/tasks/build-distro.js @@ -2,7 +2,34 @@ var bundle = require('./bundle'); -bundle({ +var path = require('path'); + +var mkdirp = require('mkdirp').sync, + cp = require('cpx').copySync, + del = require('del').sync; + +var dest = 'dist'; + + +function resolve(module, sub) { + var pkg = require.resolve(module + '/package.json'); + + return path.dirname(pkg) + sub; +} + +console.log('clean ' + dest); +del(dest); + +console.log('mkdir -p ' + dest); +mkdirp(dest); + +console.log(`copy bpmn-font to ${dest}/bpmn-font`); +cp('assets/bpmn-font/*', dest + '/assets/bpmn-font'); + +console.log(`copy diagram-js.css to ${dest}`); +cp(resolve('diagram-js', '/assets/**'), dest + '/assets'); + +bundle(dest, { 'bpmn-viewer': 'lib/Viewer.js', 'bpmn-navigated-viewer': 'lib/NavigatedViewer.js', 'bpmn-modeler': 'lib/Modeler.js' diff --git a/tasks/copy-assets.js b/tasks/copy-assets.js deleted file mode 100644 index 869e985e..00000000 --- a/tasks/copy-assets.js +++ /dev/null @@ -1,12 +0,0 @@ -'use strict'; - -var path = require('path'); - -var copySync = require('cpx').copySync; - -var diagramAssets = path.join(path.dirname(require.resolve('diagram-js')), '/assets') + '/**'; - -console.log(diagramAssets); - -copySync('assets/**', 'dist/'); -copySync(diagramAssets, 'dist/'); \ No newline at end of file