updateVersionPlugin.js 578 B

1234567891011121314151617181920
  1. var fs = require('fs');
  2. var path = require('path');
  3. var versionStringFun = require('./versionFileHelper');
  4. function writeVersionFile () {
  5. var versionString = versionStringFun();
  6. var fileData = `{ "version":"${versionString}" }`;
  7. var filePath = path.join(__dirname, '.ima_version.json');
  8. fs.writeFileSync(filePath, fileData);
  9. }
  10. function UpdateVersionPlugin () { }
  11. UpdateVersionPlugin.prototype.apply = function (compiler) {
  12. compiler.hooks.beforeCompile.tap("UpdateVersionPlugin", function () {
  13. writeVersionFile();
  14. });
  15. }
  16. module.exports = UpdateVersionPlugin;