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

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

问题描述

我想在 --watch 模式下运行 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天全站免登陆