我正在使用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 –