Tone.js/grunt/Gruntfile.js

164 lines
3.9 KiB
JavaScript
Raw Normal View History

module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
//pkg: grunt.file.readJSON("package.json"),
jsdoc : {
src : {
2014-09-04 18:02:25 +00:00
src: ["../Tone/**/*.js", "!../Tone/*/preset/*", "../README.md"],
options: {
destination: "../doc",
2014-09-24 16:07:50 +00:00
template : "./vendor",
configure : "./vendor/jsdoc.conf.json",
private : false
}
},
},
requirejs : {
compile: {
options: {
baseUrl: "../",
name : "main",
out: "./Tone.js.tmp",
optimize : "none"
}
2014-09-04 18:02:25 +00:00
},
min: {
options: {
baseUrl: "../",
name : "main",
out: "./Tone.min.js.tmp",
optimize : "uglify2"
}
}
},
copy : {
npm : {
files : [{
expand : true,
2014-09-11 18:02:11 +00:00
src: ["../build/Tone.js", "../build/Tone.min.js", "../build/Tone.Preset.js"],
2014-09-24 16:07:50 +00:00
dest: "../utils/npm/Tone.js"
2014-09-04 18:02:25 +00:00
}, {
src : ["../Tone/**"],
2014-09-24 16:07:50 +00:00
dest : "../utils/npm/Tone/"
2014-09-11 18:02:11 +00:00
}, {
src : ["../README.md"],
2014-09-24 16:07:50 +00:00
dest : "../utils/npm/README.md"
2014-09-04 18:02:25 +00:00
}]
}
},
concat: {
dist: {
options: {
banner: "require([",
separator: ",",
process: function(src, filepath) {
return "\"" + filepath.substring(3,(filepath.length-3)) + "\"";
},
footer: "], function(){});",
},
files: {
2014-09-04 18:02:25 +00:00
//exclude presets
"../main.js" : ["../Tone/**/*.js", "!../Tone/*/preset/*"],
}
},
presets : {
files: {
2014-09-05 03:56:34 +00:00
"../build/Tone.Preset.js" : ["../Tone/**/preset/*.js"],
}
},
removeRequireString: {
options: {
2014-09-24 16:07:50 +00:00
process: function(src) {
var withoutRequire = src.substr(0, src.indexOf("require([") - 1);
return withoutRequire;
},
},
files: {
2014-09-30 03:42:35 +00:00
"../build/Tone.js" : ["./Tone.js.tmp"],
}
2014-09-04 18:02:25 +00:00
},
removeRequireStringMin: {
options: {
2014-09-24 16:07:50 +00:00
process: function(src) {
2014-09-04 18:02:25 +00:00
var withoutRequire = src.substr(0, src.indexOf("require([") - 1);
return withoutRequire;
},
},
files: {
2014-09-30 03:42:35 +00:00
"../build/Tone.min.js" : ["./Tone.min.js.tmp"],
2014-09-04 18:02:25 +00:00
}
}
},
clean: {
options: {
force: true,
},
2014-09-04 18:02:25 +00:00
dist: ["../main.js","./Tone.js.tmp"],
min: ["../main.js","./Tone.min.js.tmp"],
2014-09-24 16:07:50 +00:00
},
wrap: {
dist: {
src: ["../build/Tone.js"],
2014-09-24 16:07:50 +00:00
dest: "../build/Tone.js",
options: {
wrapper: [grunt.file.read("./fragments/before.frag"), grunt.file.read("./fragments/after.frag")]
}
},
presets: {
src: ["../build/Tone.Preset.js"],
dest: "../build/Tone.Preset.js",
options: {
wrapper: [grunt.file.read("./fragments/before.preset.frag"), grunt.file.read("./fragments/after.frag")]
}
},
min: {
src: ["../build/Tone.min.js"],
dest: "../build/Tone.min.js",
options: {
wrapper: [grunt.file.read("./fragments/before.frag.min"), grunt.file.read("./fragments/after.frag.min")]
}
2014-09-24 16:07:50 +00:00
}
},
indent: {
dist: {
src: ["./Tone.js.tmp"],
dest: "./Tone.js.tmp",
options: {
style: "tab",
size: 4,
change: 1
}
},
presets: {
src: ["../build/Tone.Preset.js"],
dest: "../build/Tone.Preset.js",
options: {
style: "tab",
size: 1,
change: 1
}
}
}
});
// Load the plugin that provides the "uglify" task.
grunt.loadNpmTasks("grunt-jsdoc");
2014-09-24 16:07:50 +00:00
grunt.loadNpmTasks("grunt-wrap");
grunt.loadNpmTasks("grunt-indent");
grunt.loadNpmTasks("grunt-contrib-requirejs");
grunt.loadNpmTasks("grunt-contrib-concat");
grunt.loadNpmTasks("grunt-contrib-clean");
grunt.loadNpmTasks("grunt-contrib-copy");
// Default task(s).
grunt.registerTask("docs", ["jsdoc:src"]);
grunt.registerTask("npm", ["copy:npm"]);
grunt.registerTask("presets", ["concat:presets", "wrap:presets"]);
grunt.registerTask("min", ["concat:dist", "requirejs:min", "concat:removeRequireStringMin", "clean:min", "wrap:min"]);
grunt.registerTask("build", ["concat:dist","requirejs:compile","concat:removeRequireString", "clean:dist", "wrap:dist"]);
2014-09-04 18:02:25 +00:00
grunt.registerTask("buildall", ["build", "min", "presets"]);
grunt.registerTask("dist", ["buildall", "docs", "npm"]);
};