我正在使用webpack和webpack-dev-server。如何挂钩到webpack-dev-server构建?
我想在我的html页面上显示git describe
输出。
webpack-dev-server rebuild有没有办法挂钩,执行git describe
,并把输出放在页面的某个地方?
我正在使用webpack和webpack-dev-server。如何挂钩到webpack-dev-server构建?
我想在我的html页面上显示git describe
输出。
webpack-dev-server rebuild有没有办法挂钩,执行git describe
,并把输出放在页面的某个地方?
如果您是using webpack with grunt,您可以包括grunt-git-describe
npm package。
这将允许你包括"git-describe" task
和或保存其输出:
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');
});
我的解决办法:我写插件的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');
});
};
如何将其插入? –
@AlexanderGladysh官方文档https://webpack.github.io/docs/using-plugins.html –