Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions tasks/inline.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ module.exports = function(grunt) {
function isBase64Path( url ){
return url.match(/^'?data.*base64/);
}

function isInlineSVG( url ){
return url.match(/^'?data.*svg\+xml/);
}

// code from grunt-contrib-copy, with a little modification
function detectDestType(dest) {
Expand Down Expand Up @@ -187,7 +191,7 @@ module.exports = function(grunt) {
fileContent = fileContent.replace(/url\(["']*([^)'"]+)["']*\)/g, function(matchedWord, imgUrl){
var newUrl = imgUrl;
var flag = imgUrl.indexOf(options.tag)!=-1; // urls like "img/bg.png?__inline" will be transformed to base64
if(isBase64Path(imgUrl) || isRemotePath(imgUrl)){
if(isBase64Path(imgUrl) || isInlineSVG(imgUrl) || isRemotePath(imgUrl)){
return matchedWord;
}
grunt.log.debug( 'imgUrl: '+imgUrl);
Expand Down Expand Up @@ -220,7 +224,7 @@ module.exports = function(grunt) {
var newUrl = imgUrl;
var flag = !!imgUrl.match(/\?__inline/); // urls like "img/bg.png?__inline" will be transformed to base64
grunt.log.debug('flag:'+flag);
if(isBase64Path(imgUrl) || isRemotePath(imgUrl)){
if(isBase64Path(imgUrl) || isInlineSVG(imgUrl) || isRemotePath(imgUrl)){
return matchedWord;
}
grunt.log.debug( 'imgUrl: '+imgUrl);
Expand Down