Created
August 7, 2017 07:59
-
-
Save hostmaster/6ee9b8d015334297461c57f5ce67a221 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import fs from 'fs' | |
import path from 'path' | |
import config from '../constants/config.js' | |
const fs = require('fs') | |
const template_dir = path.resolve(__dirname, '../public') | |
const template_file = 'index.html' | |
const version = config.version.replace(/\./g, '') | |
fs.readFile(path.resolve(template_dir, template_file), 'utf8', (err, data) => { | |
if (err) return console.log(`Error while reading ${template_file}`) | |
const new_html = data.replace('bundle.js', `bundle_${version}.js`) | |
const new_html_file_name = `index_${version}.html` | |
fs.writeFile(`${template_dir}/${new_html_file_name}`, new_html, (err) => { | |
if (err) return console.log(`Error while writing ${new_html_file_name}`) | |
console.log(`GENERATED ${new_html_file_name}`) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment