change gruntfile to build a single build with support for requireJS or standalone
parent
95f4e4f7e2
commit
fe21b6a759
23
Gruntfile.js
23
Gruntfile.js
|
@ -28,6 +28,7 @@ module.exports = function(grunt) {
|
|||
dest: "dist/" + pkg.name.toLowerCase() + ".js",
|
||||
src: [
|
||||
"./node_modules/eve/eve.js",
|
||||
"./src/amd-banner.js",
|
||||
"./src/mina.js",
|
||||
"./node_modules/elemental.js/elemental.js",
|
||||
"./src/svg.js",
|
||||
|
@ -35,30 +36,12 @@ module.exports = function(grunt) {
|
|||
"./src/set.js",
|
||||
"./src/equal.js",
|
||||
"./src/mouse.js",
|
||||
"./src/filter.js"
|
||||
"./src/filter.js",
|
||||
"./src/amd-footer.js",
|
||||
]
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Run 'grunt --requirejs' for AMD/requirejs compatible build
|
||||
if (grunt.option("requirejs")) {
|
||||
var concat = grunt.config("concat");
|
||||
|
||||
// Include eve in banner, wrap savage in define function
|
||||
concat.options.banner += "\n"
|
||||
+ grunt.file.read("./node_modules/eve/eve.js")
|
||||
+ ' define(["eve"], function(eve) {';
|
||||
concat.options.footer = "\n return Savage; \n });";
|
||||
|
||||
// Remove eve from src list
|
||||
var first = concat.target.src.shift();
|
||||
if(first.indexOf("/eve.js") < 0) {
|
||||
throw Error("Expected first file to be eve.js for requirejs build");
|
||||
}
|
||||
|
||||
grunt.config("concat", concat);
|
||||
}
|
||||
|
||||
grunt.loadNpmTasks("grunt-contrib-concat");
|
||||
grunt.loadNpmTasks("grunt-contrib-uglify");
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
(function (glob, factory) {
|
||||
// AMD support
|
||||
if (typeof define === "function" && define.amd) {
|
||||
// Define as an anonymous module
|
||||
define(["eve"], function( eve ) {
|
||||
return factory(glob, eve);
|
||||
});
|
||||
} else {
|
||||
// Browser globals (glob is window)
|
||||
// Savage adds itself to window
|
||||
factory(glob, glob.eve);
|
||||
}
|
||||
}(this, function (window, eve) {
|
|
@ -0,0 +1,2 @@
|
|||
return Savage;
|
||||
}));
|
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
var Savage = (function () {
|
||||
var Savage = (function() {
|
||||
Savage.version = "0.0.1";
|
||||
/*\
|
||||
* Savage
|
||||
|
@ -3713,5 +3713,6 @@ eve.on("savage.util.getattr", function () {
|
|||
Savage.plugin = function (f) {
|
||||
f(Savage, Element, Paper, glob);
|
||||
};
|
||||
glob.win.Savage = Savage;
|
||||
return Savage;
|
||||
}());
|
Loading…
Reference in New Issue