From 4347db2c3a1c71726e648dbe4d3572b1944c364e Mon Sep 17 00:00:00 2001 From: Xaver Maierhofer Date: Thu, 16 Jun 2016 20:35:09 +0200 Subject: [PATCH] [TASK] Support comments in config.json --- Gruntfile.js | 4 ++-- config.json | 9 +++++++-- package.json | 1 + tasks/build.js | 21 +++++++++++++++++---- tasks/development.js | 4 ++-- 5 files changed, 29 insertions(+), 10 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 886ad80..3ff09ba 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -3,7 +3,7 @@ module.exports = function (grunt) { grunt.loadTasks("tasks"); - grunt.registerTask("default", ["bower-install-simple", "lint", "copy", "sass:dist", "postcss", "requirejs:default", "inlinedata", "cachebreaker", "inline", "clean:release"]); + grunt.registerTask("default", ["bower-install-simple", "lint", "copy", "sass:dist", "postcss", "requirejs:default", "inlinedata", "cachebreaker", "inline", "htmlmin", "clean:release"]); grunt.registerTask("lint", ["sasslint", "eslint"]); - grunt.registerTask("serve", ["bower-install-simple", "lint", "copy", "sass:dev", "postcss", "requirejs:dev", "inlinedata", "browserSync", "watch"]); + grunt.registerTask("serve", ["bower-install-simple", "lint", "copy", "sass:dev", "postcss", "requirejs:dev", "inlinedata", "htmlmin", "browserSync", "watch"]); }; diff --git a/config.json b/config.json index 647211a..8c4de1b 100644 --- a/config.json +++ b/config.json @@ -1,4 +1,6 @@ +// Grunt will remove all comments { + // Variables are NODE_ID and NODE_NAME (only a-z0-9\- other chars are replaced with _) "nodeInfos": [ { "name": "Clientstatistik", @@ -21,6 +23,7 @@ "caption": "Jahresstatistik - weiteren Statistiken" } ], + // String or array of data provider are supported "dataPath": "https://regensburg.freifunk.net/data/", "siteName": "Freifunk Regensburg", "mapSigmaScale": 0.5, @@ -29,7 +32,8 @@ "mapLayers": [ { "name": "HERE", - "url": "https://{s}.base.maps.api.here.com/maptile/2.1/maptile/newest/normal.day/{z}/{x}/{y}/256/png8?app_id=Q40ik5rnMQOpOQ6RrHCr&app_code=kIPJpCtUZMTiQQJiCemX6Q&lg=deu", + // Please use your own API key - Free plan is on right side after the pay plans + "url": "https://{s}.base.maps.api.here.com/maptile/2.1/maptile/newest/normal.day/{z}/{x}/{y}/256/png8?app_id=YOUR_KEY&app_code=YOUR_CODE&lg=deu", "config": { "attribution": "Map © 1987-2014 HERE", "subdomains": "1234", @@ -54,7 +58,8 @@ }, { "name": "HERE.hybridDay", - "url": "https://{s}.aerial.maps.api.here.com/maptile/2.1/maptile/newest/{variant}/{z}/{x}/{y}/256/png8?app_id=Q40ik5rnMQOpOQ6RrHCr&app_code=kIPJpCtUZMTiQQJiCemX6Q&lg=deu", + // Please use your own API key - Free plan is on right side after the pay plans + "url": "https://{s}.aerial.maps.api.here.com/maptile/2.1/maptile/newest/{variant}/{z}/{x}/{y}/256/png8?app_id=YOUR_KEY&app_code=YOUR_CODE&lg=deu", "config": { "attribution": "Map © 1987-2014 HERE", "subdomains": "1234", diff --git a/package.json b/package.json index 657be3d..195b9f2 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "grunt-check-dependencies": "^0.12.0", "grunt-contrib-clean": "^1.0.0", "grunt-contrib-copy": "^1.0.0", + "grunt-contrib-htmlmin": "^1.4.0", "grunt-contrib-requirejs": "^1.0.0", "grunt-contrib-watch": "^1.0.0", "grunt-eslint": "^18.1.0", diff --git a/tasks/build.js b/tasks/build.js index 51eacf6..e632088 100644 --- a/tasks/build.js +++ b/tasks/build.js @@ -49,10 +49,10 @@ module.exports = function (grunt) { }, sass: { dev: { - options: { - sourceMap: true, - outputStyle: "expanded" - }, + options: { + sourceMap: true, + outputStyle: "expanded" + }, files: { "build/style.css": "scss/main.scss" } @@ -89,6 +89,18 @@ module.exports = function (grunt) { dest: "build/index.html" } }, + htmlmin: { + dist: { + options: { + removeComments: true, + collapseWhitespace: true, + minifyJS: true + }, + files: { + 'build/index.html': 'build/index.html' + } + } + }, inlinedata: { injs: { expand: true, @@ -153,5 +165,6 @@ module.exports = function (grunt) { grunt.loadNpmTasks("grunt-postcss"); grunt.loadNpmTasks("grunt-inline"); grunt.loadNpmTasks("grunt-inline-data"); + grunt.loadNpmTasks('grunt-contrib-htmlmin'); grunt.loadNpmTasks("grunt-cache-breaker"); }; diff --git a/tasks/development.js b/tasks/development.js index 1141388..f214b6d 100644 --- a/tasks/development.js +++ b/tasks/development.js @@ -24,8 +24,8 @@ module.exports = function (grunt) { }, watch: { html: { - files: ["html/index.html"], - tasks: ["copy", "inlinedata"] + files: ["html/index.html", "config.json"], + tasks: ["copy", "inlinedata", "htmlmin"] }, sass: { files: ["scss/**/*.scss"],