From f799ded43481cce894bfd1c2b622d6394d2f270e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Sun, 1 Jun 2014 16:57:59 +0200 Subject: [PATCH] worked on css and js asset reving, and angular partial precaching, still need to fix panel module.html, issue #418 --- src/app/components/require.config.js | 1 + src/index.html | 9 ++++++--- tasks/build_task.js | 4 +++- tasks/options/concat.js | 8 ++++++++ tasks/options/filerev.js | 6 +++++- tasks/options/htmlmin.js | 2 +- tasks/options/ngtemplates.js | 13 +++++++++++-- tasks/options/requirejs.js | 8 ++++++-- tasks/options/usemin.js | 3 --- 9 files changed, 41 insertions(+), 13 deletions(-) diff --git a/src/app/components/require.config.js b/src/app/components/require.config.js index 3849cece1b6..dffb4a4deab 100644 --- a/src/app/components/require.config.js +++ b/src/app/components/require.config.js @@ -47,6 +47,7 @@ require.config({ elasticjs: '../vendor/elasticjs/elastic-angular-client', 'bootstrap-tagsinput': '../vendor/tagsinput/bootstrap-tagsinput', + }, shim: { underscore: { diff --git a/src/index.html b/src/index.html index 592077d95ba..0200889fa23 100644 --- a/src/index.html +++ b/src/index.html @@ -7,17 +7,20 @@ Grafana - - + + + + + - + diff --git a/tasks/build_task.js b/tasks/build_task.js index 55b84027f02..afee147d16e 100644 --- a/tasks/build_task.js +++ b/tasks/build_task.js @@ -9,11 +9,13 @@ module.exports = function(grunt) { 'concat:css', 'copy:everything_but_less_to_temp', 'htmlmin:build', - 'ngtemplates:app', + 'ngtemplates', 'cssmin:build', 'ngmin:build', 'requirejs:build', + 'concat:js', 'filerev', + 'usemin', 'clean:temp', 'build:write_revision', 'uglify:dest' diff --git a/tasks/options/concat.js b/tasks/options/concat.js index d01d61fed46..6d80a4e561a 100644 --- a/tasks/options/concat.js +++ b/tasks/options/concat.js @@ -10,5 +10,13 @@ module.exports = function(config) { ], dest: '<%= srcDir %>/css/default.min.css' }, + js: { + src: [ + '<%= destDir %>/vendor/require/require.js', + '<%= destDir %>/app/components/require.config.js', + '<%= destDir %>/app/app.js', + ], + dest: '<%= destDir %>/app/app.js' + }, }; }; diff --git a/tasks/options/filerev.js b/tasks/options/filerev.js index dd81c38a965..cd9ca020500 100644 --- a/tasks/options/filerev.js +++ b/tasks/options/filerev.js @@ -6,8 +6,12 @@ module.exports = function(config) { length: 8, }, css: { - src: '<%= srcDir %>/css/default.min.css', + src: '<%= destDir %>/css/default.min.css', dest: '<%= destDir %>/css' + }, + js: { + src: '<%= destDir %>/app/app.js', + dest: '<%= destDir %>/app' } }; }; diff --git a/tasks/options/htmlmin.js b/tasks/options/htmlmin.js index 602fc1db042..b5d36b89e77 100644 --- a/tasks/options/htmlmin.js +++ b/tasks/options/htmlmin.js @@ -8,7 +8,7 @@ module.exports = function(config) { expand: true, cwd: '<%= tempDir %>', src: [ - 'index.html', + //'index.html', 'app/panels/**/*.html', 'app/partials/**/*.html' ], diff --git a/tasks/options/ngtemplates.js b/tasks/options/ngtemplates.js index b109c22346f..12104cd1609 100644 --- a/tasks/options/ngtemplates.js +++ b/tasks/options/ngtemplates.js @@ -1,9 +1,18 @@ module.exports = function(config) { return { - kibana: { + grafana: { cwd: '<%= tempDir %>', - src: 'app/**/*.html', + src: 'app/partials/**/*.html', dest: '<%= tempDir %>/app/components/partials.js', + options: { + bootstrap: function(module, script) { + return "define('components/partials', ['angular'], function(angular) { \n" + + "angular.module('kibana').run(['$templateCache', function($templateCache) { \n" + + script + + '\n}]);' + + '\n});'; + } + } } }; }; \ No newline at end of file diff --git a/tasks/options/requirejs.js b/tasks/options/requirejs.js index 57b7cb36c66..a5d0083c49a 100644 --- a/tasks/options/requirejs.js +++ b/tasks/options/requirejs.js @@ -60,7 +60,10 @@ module.exports = function(config,grunt) { 'directives/all', 'jquery.flot.pie', 'angular-sanitize', - 'angular-dragdrop' + 'angular-dragdrop', + 'panels/graphite/module', + 'panels/text/module', + 'panels/timepicker/module' ] } ]; @@ -75,7 +78,8 @@ module.exports = function(config,grunt) { requireModules.push({ name: 'panels/'+panelName+'/'+subName+'/module', exclude: ['app'] - }); }) + }); + }) } else { requireModules.push({ name: 'panels/'+panelName+'/module', diff --git a/tasks/options/usemin.js b/tasks/options/usemin.js index 154969bec32..0abd8ed4ec5 100644 --- a/tasks/options/usemin.js +++ b/tasks/options/usemin.js @@ -1,8 +1,5 @@ module.exports = function(config) { return { html: '<%= destDir %>/index.html', - options: { - assetsDirs: ['<%= destDir %>/css/'] - } }; };