Created
February 2, 2017 13:43
-
-
Save matthlavacka/ac348ac6fa139491bb5b1b92c4e8cca9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function () { | |
this.plugin("done", function (stats) { | |
var replaceInFile = function (filePath, toReplace, replacement) { | |
var replacer = function (match) { | |
console.log('Replacing in %s: %s => %s', filePath, match, replacement); | |
return replacement | |
}; | |
var str = fs.readFileSync(filePath, 'utf8'); | |
var out = str.replace(new RegExp(toReplace, 'g'), replacer); | |
fs.writeFileSync(filePath, out); | |
}; | |
var hash = stats.hash; // Build's hash, found in `stats` since build lifecycle is done. | |
replaceInFile(path.join(__dirname, '..', 'app', 'pages', 'assets.js'), | |
'main.[^.]*.css', | |
`main.${hash}.css` | |
); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment