在webpack构建之后运行命令 [英] Run command after webpack build

查看:555
本文介绍了在webpack构建之后运行命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在中运行webpack - 监视模式,并在每次构建后运行一个shell命令,将文件夹同步到另一个文件夹。

I'd like to run webpack in --watch mode, and run a shell command after each build that synchronizes a folder to another one.

我发现此插件触发了每次构建后的事件。这是有效的,但最后一个难题是从Javascript触发shell命令(用于同步)。任何关于如何实现这一点的指针都非常感谢。

I found this plugin that triggers an event after each build. That works, but the last piece of the puzzle is to trigger a shell command (for syncing) from Javascript. Any pointers on how to achieve this are greatly appreciated.

推荐答案

您可以使用内置的 child_process 模块。您还可以尝试一些node.js的shell库,例如 Shell.js 。它包装了大多数默认shell以便于使用

You can easily run any shell command with built-in child_process module. Also you can try some shell libraries for node.js, like Shell.js. It wraps most of default shell for more convenient usage

这篇关于在webpack构建之后运行命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆