Skip to content

Instantly share code, notes, and snippets.

@thomasfr
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomasfr/ce99404a4fe4f0335242 to your computer and use it in GitHub Desktop.
Save thomasfr/ce99404a4fe4f0335242 to your computer and use it in GitHub Desktop.
options: {
patterns: [
{
src: ['assets/js/**/*.js', 'assets/css/**/*.css',],
search: /@@([^@]+?)@@/g,
replace: function(matched, part, offset, string) {
if(summary[part]) {
return summary[part];
}
else {
return part;
}
}
}
]
}
var summary = {
'/js/custom/index.js' : '/js/custom/index.a67bcd.js',
'/js/custom/facilitySearch.js' : '/js/custom/facilitySearch.k89han.js',
'/img/foo/bar/eversport.png' : '/img/foo/bar/eversport.9iasdui.png',
};
var search = /@@([^@]+?)@@/g;
var htmlString = `
block append scripts
script(src="@@/js/custom/index.js@@")
<script src="@@/js/custom/boostrap.js@@"></script>
<p>
<h1>Hallo Welt</h1>
</p>
<script src="@@/js/custom/facilitySearch.js@@"></script>
`;
var cssString = `
body {
background-image: url('@@/img/foo/bar/eversport.png@@');
}
`;
var replace = function(matched, part, offset, string) {
if(summary[part]) {
return summary[part];
}
else {
return part;
}
};
htmlString.replace(search, replace);
cssString.replace(search, replace);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment