1
0
mirror of https://gitlab.com/timvisee/send.git synced 2024-11-14 15:12:48 +01:00
send/build/version_plugin.js

26 lines
537 B
JavaScript

const commit = require('git-rev-sync').short();
const pkg = require('../package.json');
const version = JSON.stringify({
commit,
source: pkg.homepage,
version: process.env.CIRCLE_TAG || `v${pkg.version}`
});
class VersionPlugin {
apply(compiler) {
compiler.hooks.emit.tap('VersionPlugin', compilation => {
compilation.assets['version.json'] = {
source() {
return version;
},
size() {
return version.length;
}
};
});
}
}
module.exports = VersionPlugin;