Tone.js/grunt/Gruntfile.js

201 lines
4.5 KiB
JavaScript
Raw Normal View History

module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
jsdoc : {
src : {
2015-02-26 16:47:44 +00:00
src: ["../Tone/*/*.js", "!../Tone/*/preset/*", "../README.md"],
options: {
2015-02-26 16:25:38 +00:00
destination: "../docs",
configure : "./jsdoc.conf.json",
template: "./node_modules/jsdoc-oblivion/template",
private : false
},
},
},
requirejs : {
compile: {
options: {
baseUrl: "../",
name : "main",
out: "./Tone.js.tmp",
optimize : "none"
}
2014-09-04 18:02:25 +00:00
},
},
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
},
},
clean: {
options: {
force: true,
},
2014-09-04 18:02:25 +00:00
dist: ["../main.js","./Tone.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.preset.frag")]
2014-09-24 16:07:50 +00:00
}
},
2014-09-24 16:07:50 +00:00
},
indent: {
dist: {
src: ["../build/Tone.js"],
dest: "../build/Tone.js",
2014-09-24 16:07:50 +00:00
options: {
style: "tab",
size: 1,
2014-09-24 16:07:50 +00:00
change: 1
}
},
presets: {
src: ["../build/Tone.Preset.js"],
dest: "../build/Tone.Preset.js",
options: {
style: "tab",
size: 1,
change: 1
}
}
},
uglify : {
2014-11-30 19:52:57 +00:00
min : {
options : {
2014-11-30 19:52:57 +00:00
preserveComments : "some",
compress: {
dead_code : true,
evaluate : true,
loops : true,
if_return : true,
hoist_vars : true,
booleans : true,
conditionals : true,
sequences : true,
comparisons : true,
hoist_funs : true,
join_vars : true,
cascade : true,
},
},
files: {
"../build/Tone.min.js": ["../build/Tone.js"]
}
2014-11-30 19:52:57 +00:00
},
},
replace: {
dist: {
options: {
patterns: [
{
2015-02-28 04:25:07 +00:00
match: /define\('([^']*)'\w*,\w*\[([^\]]*)\]\w*,\w*/g,
2015-02-21 19:04:20 +00:00
replacement: "ToneModule("
},
{
2015-02-28 04:25:07 +00:00
match: /define\('Tone\/core\/Tone',\[\],/gi,
2015-04-24 21:42:25 +00:00
replacement: "ToneCore("
},
{
match: /\n"use strict";\n/g,
replacement: ""
}
]
},
files: [{
src: ["../build/Tone.js"],
dest: "../build/Tone.js"
}]
},
presets: {
options: {
patterns: [
{
match: /define\(\w*\[([^\]]*)\]\w*,\w*/g,
2015-02-21 19:04:20 +00:00
replacement: "TonePreset("
}
]
},
files: [{
src: ["../build/Tone.Preset.js"],
dest: "../build/Tone.Preset.js"
}]
}
}
});
// 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");
grunt.loadNpmTasks("grunt-replace");
grunt.loadNpmTasks("grunt-contrib-uglify");
// Default task(s).
grunt.registerTask("docs", ["jsdoc:src"]);
grunt.registerTask("npm", ["copy:npm"]);
grunt.registerTask("presets", ["concat:presets", "indent:presets", "replace:presets", "wrap:presets"]);
2014-11-30 19:52:57 +00:00
grunt.registerTask("min", ["uglify:min"]);
grunt.registerTask("build", ["concat:dist","requirejs:compile","concat:removeRequireString", "clean:dist", "indent:dist", "replace:dist", "wrap:dist"]);
2014-09-04 18:02:25 +00:00
grunt.registerTask("buildall", ["build", "min", "presets"]);
grunt.registerTask("dist", ["buildall", "docs", "npm"]);
2015-03-26 14:57:49 +00:00
grunt.registerTask("default", ["buildall"]);
};