Created
May 1, 2016 13:51
-
-
Save marcelpanse/65f5044198a6e47db0784db2da99105f 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
/* // call this from your package.json like: | |
"scripts": { | |
"build-static": "webpack && node lib/build-static.js" | |
} | |
*/ | |
var shell = require('shelljs') | |
shell.cp('-f', 'app/index.html', 'build/public/index.html') | |
var fs = require('fs') | |
fs.readFile('build/public/index.html', 'utf8', function (err, data) { | |
if (err) { | |
return console.log(err) | |
} | |
var timestamp = Date.now() | |
var result = data.replace('SCRIPT_URL', '/main.js?cache=' + timestamp).replace('STYLE_URL', '/main.css?cache=' + timestamp) | |
fs.writeFile('build/public/index.html', result, 'utf8', function (error) { | |
if (error) { | |
return console.log(error) | |
} | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment