2013-02-13 07:40:08 +04:00
|
|
|
module.exports = function(grunt) {
|
2013-02-15 22:58:57 +04:00
|
|
|
|
2013-03-12 21:49:48 +04:00
|
|
|
// ----------
|
2013-02-15 22:58:57 +04:00
|
|
|
grunt.loadNpmTasks("grunt-contrib-compress");
|
2013-02-21 22:54:11 +04:00
|
|
|
grunt.loadNpmTasks("grunt-contrib-concat");
|
|
|
|
grunt.loadNpmTasks("grunt-contrib-jshint");
|
|
|
|
grunt.loadNpmTasks("grunt-contrib-uglify");
|
|
|
|
grunt.loadNpmTasks("grunt-contrib-qunit");
|
|
|
|
grunt.loadNpmTasks("grunt-contrib-connect");
|
|
|
|
grunt.loadNpmTasks("grunt-contrib-watch");
|
2013-02-27 21:59:51 +04:00
|
|
|
grunt.loadNpmTasks("grunt-contrib-clean");
|
2013-02-15 22:58:57 +04:00
|
|
|
|
2013-03-12 21:49:48 +04:00
|
|
|
// ----------
|
2013-02-21 23:56:16 +04:00
|
|
|
var distribution = "build/openseadragon/openseadragon.js",
|
|
|
|
minified = "build/openseadragon/openseadragon.min.js",
|
2013-02-13 07:40:08 +04:00
|
|
|
sources = [
|
|
|
|
"src/openseadragon.js",
|
2013-03-07 00:36:52 +04:00
|
|
|
"src/fullscreen.js",
|
2013-02-13 07:40:08 +04:00
|
|
|
"src/eventhandler.js",
|
|
|
|
"src/mousetracker.js",
|
|
|
|
"src/control.js",
|
|
|
|
"src/controldock.js",
|
|
|
|
"src/viewer.js",
|
|
|
|
"src/navigator.js",
|
|
|
|
"src/strings.js",
|
|
|
|
"src/point.js",
|
|
|
|
//"src/profiler.js",
|
|
|
|
"src/tilesource.js",
|
|
|
|
"src/dzitilesource.js",
|
|
|
|
"src/iiiftilesource.js",
|
|
|
|
"src/osmtilesource.js",
|
|
|
|
"src/tmstilesource.js",
|
|
|
|
"src/legacytilesource.js",
|
|
|
|
"src/tilesourcecollection.js",
|
|
|
|
"src/button.js",
|
|
|
|
"src/buttongroup.js",
|
|
|
|
"src/rectangle.js",
|
|
|
|
"src/referencestrip.js",
|
|
|
|
"src/displayrectangle.js",
|
|
|
|
"src/spring.js",
|
|
|
|
"src/tile.js",
|
|
|
|
"src/overlay.js",
|
|
|
|
"src/drawer.js",
|
|
|
|
"src/viewport.js"
|
|
|
|
];
|
|
|
|
|
2013-03-12 21:49:48 +04:00
|
|
|
// ----------
|
2013-02-13 07:40:08 +04:00
|
|
|
// Project configuration.
|
|
|
|
grunt.initConfig({
|
2013-02-21 22:54:11 +04:00
|
|
|
pkg: grunt.file.readJSON("package.json"),
|
2013-02-27 21:59:51 +04:00
|
|
|
clean: {
|
|
|
|
build: ["build"],
|
|
|
|
release: {
|
|
|
|
src: [
|
|
|
|
"../site-build/openseadragon",
|
|
|
|
"../site-build/openseadragon.zip",
|
|
|
|
"../site-build/openseadragon.tar"
|
|
|
|
],
|
|
|
|
options: {
|
|
|
|
force: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2013-02-13 07:40:08 +04:00
|
|
|
concat: {
|
2013-02-21 22:45:14 +04:00
|
|
|
options: {
|
2013-03-11 22:52:30 +04:00
|
|
|
banner: "//! <%= pkg.name %> <%= pkg.version %>\n"
|
|
|
|
+ "//! Built on <%= grunt.template.today('yyyy-mm-dd') %>\n"
|
|
|
|
+ "//! http://openseadragon.github.com\n\n",
|
|
|
|
process: true
|
2013-02-21 22:45:14 +04:00
|
|
|
},
|
2013-02-13 07:40:08 +04:00
|
|
|
dist: {
|
2013-02-15 00:02:17 +04:00
|
|
|
src: [ "<banner>" ].concat(sources),
|
2013-02-13 07:40:08 +04:00
|
|
|
dest: distribution
|
|
|
|
}
|
|
|
|
},
|
2013-02-21 22:45:14 +04:00
|
|
|
uglify: {
|
2013-03-11 22:52:30 +04:00
|
|
|
options: {
|
|
|
|
preserveComments: "some"
|
|
|
|
},
|
2013-02-14 22:21:35 +04:00
|
|
|
openseadragon: {
|
|
|
|
src: [ distribution ],
|
|
|
|
dest: minified
|
|
|
|
}
|
|
|
|
},
|
2013-02-15 22:58:57 +04:00
|
|
|
compress: {
|
|
|
|
zip: {
|
2013-02-21 23:56:16 +04:00
|
|
|
options: {
|
|
|
|
archive: "build/openseadragon.zip"
|
|
|
|
},
|
|
|
|
files: [
|
|
|
|
{ expand: true, cwd: "build/", src: ["openseadragon/**"] }
|
|
|
|
]
|
2013-02-15 22:58:57 +04:00
|
|
|
},
|
|
|
|
tar: {
|
2013-02-21 23:56:16 +04:00
|
|
|
options: {
|
|
|
|
archive: "build/openseadragon.tar"
|
|
|
|
},
|
|
|
|
files: [
|
|
|
|
{ expand: true, cwd: "build/", src: [ "openseadragon/**" ] }
|
|
|
|
]
|
2013-02-15 22:58:57 +04:00
|
|
|
}
|
|
|
|
},
|
2013-02-14 22:21:35 +04:00
|
|
|
qunit: {
|
2013-02-21 23:17:05 +04:00
|
|
|
all: {
|
|
|
|
options: {
|
|
|
|
urls: [ "http://localhost:8000/test/test.html" ]
|
|
|
|
}
|
|
|
|
}
|
2013-02-14 22:21:35 +04:00
|
|
|
},
|
2013-02-21 22:45:14 +04:00
|
|
|
connect: {
|
2013-02-21 23:17:05 +04:00
|
|
|
server: {
|
|
|
|
options: {
|
|
|
|
port: 8000,
|
|
|
|
base: "."
|
|
|
|
}
|
2013-02-21 22:45:14 +04:00
|
|
|
}
|
2013-02-14 22:21:35 +04:00
|
|
|
},
|
|
|
|
watch: {
|
2013-03-12 21:43:27 +04:00
|
|
|
files: [ "Gruntfile.js", "src/*.js", "images/*" ],
|
2013-02-27 21:59:51 +04:00
|
|
|
tasks: "build"
|
2013-02-14 22:21:35 +04:00
|
|
|
},
|
2013-02-13 07:40:08 +04:00
|
|
|
jshint: {
|
|
|
|
options: {
|
2013-02-21 22:45:14 +04:00
|
|
|
browser: true,
|
|
|
|
eqeqeq: false,
|
|
|
|
loopfunc: false,
|
|
|
|
globals: {
|
|
|
|
OpenSeadragon: true
|
|
|
|
}
|
2013-02-13 07:40:08 +04:00
|
|
|
},
|
2013-02-21 22:45:14 +04:00
|
|
|
beforeconcat: sources,
|
|
|
|
afterconcat: [ distribution ]
|
2013-02-13 07:40:08 +04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2013-03-12 21:49:48 +04:00
|
|
|
// ----------
|
2013-02-27 21:59:51 +04:00
|
|
|
// Copy:build task.
|
|
|
|
// Copies the image files into the appropriate location in the build folder.
|
|
|
|
grunt.registerTask("copy:build", function() {
|
2013-02-15 01:24:50 +04:00
|
|
|
grunt.file.recurse("images", function(abspath, rootdir, subdir, filename) {
|
2013-02-21 23:56:16 +04:00
|
|
|
grunt.file.copy(abspath, "build/openseadragon/images/" + (subdir || "") + filename);
|
2013-02-15 01:24:50 +04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2013-03-12 21:49:48 +04:00
|
|
|
// ----------
|
2013-02-27 21:59:51 +04:00
|
|
|
// Copy:release task.
|
|
|
|
// Copies the contents of the build folder into ../site-build.
|
|
|
|
grunt.registerTask("copy:release", function() {
|
|
|
|
grunt.file.recurse("build", function(abspath, rootdir, subdir, filename) {
|
2013-02-27 22:36:19 +04:00
|
|
|
var dest = "../site-build/"
|
2013-03-05 16:30:37 +04:00
|
|
|
+ (subdir ? subdir + "/" : '/')
|
2013-02-27 22:36:19 +04:00
|
|
|
+ filename;
|
|
|
|
|
|
|
|
grunt.file.copy(abspath, dest);
|
2013-02-27 21:59:51 +04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2013-03-12 21:49:48 +04:00
|
|
|
// ----------
|
2013-02-27 21:59:51 +04:00
|
|
|
// Build task.
|
|
|
|
// Cleans out the build folder and builds the code and images into it, checking lint.
|
|
|
|
grunt.registerTask("build", [
|
|
|
|
"clean:build", "jshint:beforeconcat", "concat", "jshint:afterconcat", "uglify", "copy:build"
|
|
|
|
]);
|
2013-02-14 22:21:35 +04:00
|
|
|
|
2013-03-12 21:49:48 +04:00
|
|
|
// ----------
|
2013-02-14 22:21:35 +04:00
|
|
|
// Test task.
|
2013-02-27 21:59:51 +04:00
|
|
|
// Builds and runs unit tests.
|
|
|
|
grunt.registerTask("test", ["build", "connect", "qunit"]);
|
2013-02-13 07:40:08 +04:00
|
|
|
|
2013-03-12 21:49:48 +04:00
|
|
|
// ----------
|
2013-02-15 22:58:57 +04:00
|
|
|
// Package task.
|
2013-02-27 21:59:51 +04:00
|
|
|
// Builds and creates the .zip and .tar files.
|
|
|
|
grunt.registerTask("package", ["build", "compress"]);
|
2013-02-20 07:53:54 +04:00
|
|
|
|
2013-03-12 21:49:48 +04:00
|
|
|
// ----------
|
2013-02-27 21:59:51 +04:00
|
|
|
// Publish task.
|
|
|
|
// Cleans the built files out of ../site-build and copies newly built ones over.
|
|
|
|
grunt.registerTask("publish", ["package", "clean:release", "copy:release"]);
|
|
|
|
|
2013-03-12 21:49:48 +04:00
|
|
|
// ----------
|
2013-02-27 21:59:51 +04:00
|
|
|
// Default task.
|
|
|
|
// Does a normal build.
|
|
|
|
grunt.registerTask("default", ["build"]);
|
2013-02-14 22:21:35 +04:00
|
|
|
};
|