How to connect to webpack-dev-server assembly?

I use webpack and webpack-dev server.

I want to display the output git describein my html page.

Is there a way to intercept webpack-dev-server, execute git describeand put the output somewhere on the page?

+4
source share
2 answers

If you are using webpack with grunt , you can enable grunt-git-describenpm .

This will allow you to enable "git-describe" taskand save its output:

grunt.registerTask('saveRevision', function() {
    grunt.event.once('git-describe', function (rev) {
        grunt.log.writeln("Git Revision: " + rev);
        grunt.option('gitRevision', rev);
    });    
    grunt.task.run('git-describe');
});
+2
source

My solution: I wrote a plugin for webpack

var GitDescribePlugin = function(/*options*/) {
};

GitDescribePlugin.prototype.apply = function(compiler) {
  compiler.plugin("compile", function(/*params*/) {
    console.log("The compiler is starting to compile...");
    child_process.execSync('git describe --always > gitdescribe.txt');
  });
};
+2
source

Source: https://habr.com/ru/post/1617221/


All Articles