Commit c21b5836 authored by Daniel Gerhardt's avatar Daniel Gerhardt
Browse files

Refactor Grunt build analogous to Presenter

parent b2b6f160
/* global module: true */
/* jshint browser: false, node: true */
"use strict";
module.exports = function (grunt) {
"use strict";
// The final output directory.
/* The final output directory. */
var outdir = "build/";
// A temporary directory used by amdserialize to output the processed modules.
/* A temporary directory used by amdserialize to output the processed
* modules. */
var tmpdir = outdir + "tmp/";
// The grunt.config property populated by amdserialize, containing the
// list of files to include in the layer.
/* The grunt.config property populated by amdserialize, containing the list
* of files to include in the layer. */
var outprop = "amdoutput";
// The requirejs baseUrl.
/* The requirejs baseUrl. */
var baseUrl = "./";
grunt.initConfig({
// The loader config should go here.
/* The loader config should go here. */
amdloader: {
baseUrl: baseUrl,
// Enable build of requirejs-text/text
/* Enable build of requirejs-text/text */
inlineText: true,
// Here goes the config for the amd plugins build process (has, i18n, ecma402...).
/* Here goes the config for the amd plugins build process (has,
* i18n, ecma402...). */
config: {
},
......@@ -43,15 +46,16 @@ module.exports = function (grunt) {
]
},
// The common build config
/* The common build config */
amdbuild: {
// dir is the output directory.
/* dir is the output directory. */
dir: tmpdir,
// List of plugins that the build should not try to resolve at build time.
/* List of plugins that the build should not try to resolve at build
* time. */
runtimePlugins: [],
// List of layers to build.
/* List of layers to build. */
layers: [{
name: "libarsnova/libarsnova",
include: [
......@@ -67,13 +71,16 @@ module.exports = function (grunt) {
"libarsnova/socket"
],
includeShallow: [
// Only the modules listed here (ie. NOT their dependencies) will be added to the layer.
/* Only the modules listed here (ie. NOT their dependencies)
* will be added to the layer. */
],
exclude: [
// Modules and layers listed here, and their dependencies, will NOT be in the layer.
/* Modules and layers listed here, and their dependencies,
* will NOT be in the layer. */
],
excludeShallow: [
// Only the modules listed here (ie. NOT their dependencies) will NOT be in the layer.
/* Only the modules listed here (ie. NOT their dependencies)
* will NOT be in the layer. */
]
}]
},
......@@ -93,13 +100,13 @@ module.exports = function (grunt) {
}
},
// Erase previous build.
/* Erase previous build. */
clean: {
build: [outdir],
tmp: [tmpdir]
},
// Copy the plugin files to the real output directory.
/* Copy the plugin files to the real output directory. */
copy: {
plugins: {
expand: true,
......@@ -131,9 +138,14 @@ module.exports = function (grunt) {
}
},
// Config to allow uglify to generate the layer.
/* Config to allow uglify to generate the layer. */
uglify: {
options: {
/* jshint ignore: start */
compress: {
drop_console: true
},
/* jshint ignore: end */
sourceMap: true
},
amd: {
......@@ -177,12 +189,10 @@ module.exports = function (grunt) {
}
});
// The main build task.
grunt.registerTask("amdbuild", function (amdloader) {
grunt.registerTask("amdbuild", function (amdloader, includeLoader) {
var name = this.name,
layers = grunt.config(name).layers,
uglifyTask = grunt.config("amdbuild").includeLoader ? "requirejs" : "amd"
uglifyTask = "includeloader" === includeLoader ? "requirejs" : "amd"
;
layers.forEach(function (layer) {
......@@ -193,15 +203,36 @@ module.exports = function (grunt) {
});
});
grunt.registerTask("includerequirejs", function (amdloader) {
grunt.config("amdbuild.includeLoader", true);
});
grunt.registerTask("build", function (target) {
if (!target) {
target = "dojo";
}
grunt.registerTask("build", function (amdloader) {
grunt.log.writeln("Please use one of the following tasks to build libarsnova:");
grunt.log.writeln("* build:dojo This build includes the Dojo loader [default]");
grunt.log.writeln("* build:requirejs This build includes the RequireJS loader");
grunt.log.writeln("* build:amd This build includes no loader");
var taskList;
switch (target) {
case "amd":
taskList = ["amdbuild:amdloader", "amdreportjson:amdbuild"];
break;
case "requirejs":
taskList = ["amdbuild:amdloader:includeloader", "amdreportjson:amdbuild"];
break;
case "dojo":
taskList = ["symlink:dojo", "dojo:dist", "uglify:dojo", "copy:dojoreport"];
break;
default:
grunt.log.writeln("Please use one of the following tasks to build libarsnova:");
grunt.log.writeln("* build:dojo This build includes the Dojo loader [default]");
grunt.log.writeln("* build:requirejs This build includes the RequireJS loader");
grunt.log.writeln("* build:amd This build includes no loader");
return;
}
grunt.task.run(["clean", "jshint", "shell:bowerdeps"]);
grunt.task.run(taskList);
grunt.task.run("clean:tmp");
});
grunt.loadNpmTasks("grunt-amd-build");
......@@ -213,8 +244,5 @@ module.exports = function (grunt) {
grunt.loadNpmTasks("grunt-dojo");
grunt.loadNpmTasks("grunt-shell");
grunt.registerTask("build:amd", ["clean", "jshint", "shell:bowerdeps", "amdbuild:amdloader", "amdreportjson:amdbuild", "clean:tmp"]);
grunt.registerTask("build:requirejs", ["includerequirejs", "build:amd"]);
grunt.registerTask("build:dojo", ["clean", "jshint", "shell:bowerdeps", "symlink:dojo", "dojo:dist", "uglify:dojo", "copy:dojoreport", "clean:tmp"]);
grunt.registerTask("default", ["build:dojo"]);
grunt.registerTask("default", ["build"]);
};
......@@ -3,7 +3,7 @@
"version": "1.0.0-alpha",
"description": "libarsnova is a client library for the Audience Response System ARSnova which transparently handles communication with the backend API.",
"authors": [
"Daniel Gerhardt <code@dgerhardt.net>"
"Daniel Gerhardt <code@dgerhardt.net> (http://dgerhardt.net)"
],
"license": "LGPL-3.0+",
"keywords": [
......@@ -25,10 +25,9 @@
],
"ignore": [
"**/.*",
"bower_components",
"node_modules",
"tests",
"vendor"
"CONTRIBUTING.md",
"pom.xml",
"tests"
],
"dependencies": {
"dojo": "1.10",
......
var profile = (function () {
"use strict";
var depPath = "bower_components/";
return {
basePath: "./",
action: "release",
......@@ -12,7 +14,7 @@ var profile = (function () {
defaultConfig: {
async: true,
baseUrl: "src",
baseUrl: "./",
hasCache: {
"config-selectorEngine": "lite"
}
......@@ -21,11 +23,11 @@ var profile = (function () {
packages: [
{
name: "dojo",
location: "bower_components/dojo"
location: depPath + "dojo"
},
{
name: "dstore",
location: "bower_components/dstore"
location: depPath + "dstore"
}
],
......@@ -35,7 +37,8 @@ var profile = (function () {
include: []
},
"libarsnova/libarsnova": {
customBase: true, // do not add dojo/main automatically
/* do not add dojo/main automatically */
customBase: true,
boot: true,
include: [
"dojo/request/xhr",
......@@ -51,8 +54,8 @@ var profile = (function () {
},
staticHasFeatures: {
/* These properties allow Closure compiler to remove unused code from Dojo Toolkit
* and further decrease file size of the build */
/* These properties allow Closure compiler to remove unused code
* from Dojo Toolkit and further decrease file size of the build */
"config-deferredInstrumentation": 0,
"config-dojo-loader-catches": 0,
"config-stripStrict": 0,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment