Skip to content

Instantly share code, notes, and snippets.

@marcelpanse
Created May 1, 2016 13:51
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 marcelpanse/65f5044198a6e47db0784db2da99105f to your computer and use it in GitHub Desktop.
Save marcelpanse/65f5044198a6e47db0784db2da99105f to your computer and use it in GitHub Desktop.
/* // 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