grunt-appolo-assets-url-replace
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -50,3 +50,3 @@ /* | ||
tests: ['test/*_test.js'], | ||
}, | ||
} | ||
@@ -69,3 +69,2 @@ }); | ||
grunt.registerTask('default', ['jshint', 'test']); | ||
}; |
{ | ||
"name": "grunt-appolo-assets-url-replace", | ||
"description": "Grunt task to replace assets urls with absolute path", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"author": { | ||
@@ -19,13 +19,5 @@ "name": "Roman Svichar", | ||
"type": "git", | ||
"url": "git://github.com/nanjingboy/grunt-css-url-replace.git" | ||
"url": "https://github.com/shmoop207/grunt-appolo-assets-url-replace.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/nanjingboy/grunt-css-url-replace/issues" | ||
}, | ||
"licenses": [ | ||
{ | ||
"type": "MIT", | ||
"url": "https://github.com/nanjingboy/grunt-css-url-replace/blob/master/LICENSE-MIT" | ||
} | ||
], | ||
"main": "Gruntfile.js", | ||
@@ -32,0 +24,0 @@ "engines": { |
@@ -12,3 +12,3 @@ | ||
var cssRegex = /url\s?\(['"]?(.*)(?=['"]?\))/gi; | ||
var cssRegex = /url\s*\(\s*(['"]?)([^"'\)]*)\1\s*\)/gi; | ||
var htmlRegex = /src\s?\=['"]?(.*)['"]/gi; | ||
@@ -34,2 +34,3 @@ | ||
var modified = false; | ||
var css = fs.readFileSync(filepath).toString(), | ||
@@ -44,10 +45,14 @@ match; | ||
css = css.replace(match[0], "url("+options.staticUrl + path.normalize('/'+ imagePath)+")"); | ||
modified = true; | ||
} | ||
} | ||
grunt.file.write(filepath, css); | ||
grunt.log.writeln('File "' + filepath + '" modified.'); | ||
if(modified) { | ||
grunt.file.write(filepath, css); | ||
grunt.log.writeln('File "' + filepath + '" modified.'); | ||
} | ||
} else if(ext == '.html' || ext == '.htm') { | ||
var modified = false; | ||
var html = fs.readFileSync(filepath).toString(), | ||
@@ -59,11 +64,12 @@ match; | ||
console.log(match[0]); | ||
if (imagePath.indexOf("http://") == -1 && imagePath.indexOf(";base64") == -1 && options.ext.indexOf(path.extname(imagePath)) > -1 ) { | ||
html = html.replace(match[0], 'src="'+options.staticUrl + path.normalize('/'+ imagePath)+'"'); | ||
modified = true; | ||
} | ||
} | ||
grunt.file.write(filepath, html); | ||
grunt.log.writeln('File "' + filepath + '" modified.'); | ||
if(modified) { | ||
grunt.file.write(filepath, html); | ||
grunt.log.writeln('File "' + filepath + '" modified.'); | ||
} | ||
} | ||
@@ -70,0 +76,0 @@ |
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
6873
8
108
2