Added build files
parent
8dea670d0a
commit
3884473baf
|
@ -0,0 +1,101 @@
|
|||
var path = require("path"),
|
||||
fs = require("fs"),
|
||||
parentFolderName = path.basename(path.resolve('..')),
|
||||
mxClientContent,
|
||||
deps;
|
||||
|
||||
// To get the dependencies for the project, read the filenames by matching
|
||||
// mxClient.include([...]) in mxClient.js. This is not perfect, but the list is
|
||||
// required in mxClient.js for compatibility.
|
||||
mxClientContent = fs.readFileSync(
|
||||
path.join(__dirname, "./javascript/src/js/mxClient.js"),
|
||||
"utf8"
|
||||
);
|
||||
deps = mxClientContent.match(/mxClient\.include\([^"']+["'](.*?)["']/gi).map(function (str) {
|
||||
return "." + str.match(/mxClient\.include\([^"']+["'](.*?)["']/)[1];
|
||||
});
|
||||
deps = ["./js/mxClient.js"].concat(deps.slice(0));
|
||||
|
||||
module.exports = function (grunt) {
|
||||
grunt.initConfig({
|
||||
copy: {
|
||||
main: {
|
||||
files: [{
|
||||
expand: true,
|
||||
cwd: "./javascript/src",
|
||||
src: deps,
|
||||
dest: "./javascript/dist"
|
||||
}],
|
||||
options: {
|
||||
// After each module, add the object to the '__mxOutput' namespace
|
||||
// E.g. __mxOutput.mxLog, etc.
|
||||
process: function (content, srcpath) {
|
||||
var afterContent = "",
|
||||
moduleName = path.basename(srcpath, ".js");
|
||||
|
||||
afterContent += "\n__mxOutput." + path.basename(srcpath, ".js") +
|
||||
" = typeof " + moduleName + " !== 'undefined' ? " + moduleName + " : undefined;\n";
|
||||
|
||||
return content + afterContent;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
concat: {
|
||||
dist: {
|
||||
src: deps.map(function (dep) {
|
||||
return path.join("./javascript/dist", dep);
|
||||
}),
|
||||
dest: './javascript/dist/build.js'
|
||||
},
|
||||
options: {
|
||||
banner: "(function (root, factory) {\n" +
|
||||
"if (typeof define === 'function' && define.amd) {\n" +
|
||||
"define([], factory);\n" +
|
||||
"} else if (typeof module === 'object' && module.exports) {\n" +
|
||||
"module.exports = factory();\n" +
|
||||
"} else {\n" +
|
||||
"root.mxgraph = factory();\n" +
|
||||
"}\n" +
|
||||
"}(this, function () {\n" +
|
||||
"return function (opts) {\n" +
|
||||
// Opts will be passed into this function, expand them out as if
|
||||
// they were globals so they can get picked up by the logic in
|
||||
// mxClient.js.
|
||||
"for (var name in opts) { this[name] = opts[name]; }\n" +
|
||||
"var __mxOutput = {};\n",
|
||||
footer: "return __mxOutput;\n" +
|
||||
"};\n" +
|
||||
"}));"
|
||||
}
|
||||
},
|
||||
webpack: {
|
||||
examples: {
|
||||
entry: "./javascript/examples/webpack/src/anchors.js",
|
||||
output: {
|
||||
path: path.resolve(__dirname, "./javascript/examples/webpack/dist"),
|
||||
filename: "anchors.js"
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
javascripts: {
|
||||
files: "javascript/src/**/*.js",
|
||||
tasks: ["umdify"],
|
||||
options: {
|
||||
interrupt: true
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
require(parentFolderName === "node_modules" ? "load-grunt-parent-tasks" : "load-grunt-tasks")(grunt);
|
||||
grunt.registerTask("default", [
|
||||
"copy",
|
||||
"concat",
|
||||
"webpack"
|
||||
]);
|
||||
grunt.registerTask("build", [
|
||||
"default"
|
||||
]);
|
||||
};
|
|
@ -0,0 +1,40 @@
|
|||
<?xml version="1.0"?>
|
||||
<project basedir="." default="mxclient">
|
||||
|
||||
<taskdef name="jscomp" classname="com.google.javascript.jscomp.ant.CompileTask" classpath="compiler.jar"/>
|
||||
|
||||
<target name="mxclient">
|
||||
<delete file=".tmp.js"/>
|
||||
<java fork="false" classname="Preprocessor" classpath=".">
|
||||
<arg value="../../javascript/src/js/mxClient.js"/>
|
||||
<arg value="mxClient-debug.js"/>
|
||||
</java>
|
||||
<loadfile property="version" srcFile="../../VERSION"/>
|
||||
<replace file="mxClient-debug.js" token="@MXGRAPH-VERSION@" value="${version}"/>
|
||||
<jscomp compilationLevel="simple" debug="false" output="mxClient.js">
|
||||
<sources dir=".">
|
||||
<file name="mxClient-debug.js"/>
|
||||
</sources>
|
||||
</jscomp>
|
||||
</target>
|
||||
|
||||
<target name="grapheditor" depends="mxclient">
|
||||
<jscomp compilationLevel="simple" debug="false" output="grapheditor.min.js">
|
||||
<sources dir=".">
|
||||
<file name="mxClient.js"/>
|
||||
</sources>
|
||||
|
||||
<sources dir="${basedir}/../../javascript/examples/grapheditor/www/js">
|
||||
<file name="Editor.js"/>
|
||||
<file name="Graph.js"/>
|
||||
<file name="EditorUi.js"/>
|
||||
<file name="Actions.js"/>
|
||||
<file name="Menus.js"/>
|
||||
<file name="Sidebar.js"/>
|
||||
<file name="Toolbar.js"/>
|
||||
<file name="Dialogs.js"/>
|
||||
</sources>
|
||||
</jscomp>
|
||||
</target>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,31 @@
|
|||
{
|
||||
"name": "mxgraph",
|
||||
"description": "mxGraph is a fully client side JavaScript diagramming library that uses SVG and HTML for rendering.",
|
||||
"version": "@VERSION@",
|
||||
"homepage": "https://github.com/jgraph/mxgraph",
|
||||
"author": {
|
||||
"name": "JGraph Ltd",
|
||||
"email": "support@jgraph.com"
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/jgraph/mxgraph.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/jgraph/mxgraph/issues"
|
||||
},
|
||||
"main": "./javascript/dist/build.js",
|
||||
"scripts": {
|
||||
"postinstall": "grunt build"
|
||||
},
|
||||
"dependencies": {
|
||||
"grunt": "^1.0.1",
|
||||
"grunt-contrib-concat": "^1.0.1",
|
||||
"grunt-contrib-copy": "^1.0.0",
|
||||
"grunt-webpack": "^2.0.1",
|
||||
"load-grunt-parent-tasks": "^0.1.1",
|
||||
"load-grunt-tasks": "^3.5.2",
|
||||
"webpack": "^2.2.1"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue