Fixed asset revving issue with css files

This commit is contained in:
Torkel Ödegaard
2015-03-13 11:11:31 +01:00
parent ab307ec7f3
commit 4b3224702c
10 changed files with 46 additions and 167 deletions

View File

@@ -19,11 +19,31 @@ module.exports = function(grunt) {
'requirejs:build',
'concat:js',
'filerev',
'remapFilerev',
'usemin',
'clean:temp',
'uglify:dest'
]);
// task to add [[.AppSubUrl]] to reved path
grunt.registerTask('remapFilerev', function(){
var root = grunt.config().destDir;
var summary = grunt.filerev.summary;
var fixed = {};
for(var key in summary){
if(summary.hasOwnProperty(key)){
var orig = key.replace(root, root+'/[[.AppSubUrl]]');
var revved = summary[key].replace(root, root+'/[[.AppSubUrl]]');
fixed[orig] = revved;
}
}
grunt.filerev.summary = fixed;
});
grunt.registerTask('build-post-process', function() {
grunt.config('copy.dist_to_tmp', {
expand: true,

View File

@@ -1,7 +1,6 @@
module.exports = function(config) {
return {
on_start: ['<%= destDir %>', '<%= tempDir %>'],
temp: ['<%= tempDir %>'],
docs: ['<%= docsDir %>']
temp: ['<%= tempDir %>']
};
};
};

View File

@@ -1,11 +1,29 @@
module.exports = function(config) {
module.exports = function() {
'use strict';
return {
html: [
'<%= destDir %>/views/index.html',
'<%= destDir %>/index.html',
],
options: {
assetsDirs: ['<%= destDir %>']
assetsDirs: ['<%= destDir %>'],
patterns: {
css: [
[/(\.css)/, 'Replacing reference to image.png']
]
}
// blockReplacements: {
// css: function (block) {
// console.log('aaaaaaaaaaaaa', block);
// return '<link rel="stylesheet" href="aaaa' + block.dest + '">';
// }
// }
// css: [
// [/(grafana\.light\.min\.css)/, 'Replacing reference to light css', function(asd) {
// console.log("Match", asd);
// return 'css/grafana.light.min.css';
// }]
// ]
}
};
};

View File

@@ -2,7 +2,6 @@ module.exports = function(config) {
return {
html: [
'tmp/index.html',
'tmp/views/index.html',
]
};
};