具有多个 OS 的 Webpack 挂钩
Webpack hooks with multiple OS
我们的开发团队在 Windows 和 Linux 上。我使用编译器挂钩创建了一个 webpack 4 插件,该插件仅适用于 Linux 机器。有没有办法检测 OS 以便我可以为 Windows 人写一个替代版本?
plugins: [
{
apply: (compiler) => {
compiler.hooks.afterEmit.tap("AfterEmitPlugin", () => {
exec("sh generate-templates.sh src/main/resources/public/js", (err, stdout, stderr) => {
if (stdout) process.stdout.write(stdout);
if (stderr) process.stderr.write(stderr);
});
});
},
},
],
在 Node.js 而不是 shell 中编写插件,OS 兼容性应该没有问题。
plugins: [
{
apply: (compiler) => {
compiler.hooks.afterEmit.tap("AfterEmitPlugin", () => {
...use node here.
});
},
},
],
我们的开发团队在 Windows 和 Linux 上。我使用编译器挂钩创建了一个 webpack 4 插件,该插件仅适用于 Linux 机器。有没有办法检测 OS 以便我可以为 Windows 人写一个替代版本?
plugins: [
{
apply: (compiler) => {
compiler.hooks.afterEmit.tap("AfterEmitPlugin", () => {
exec("sh generate-templates.sh src/main/resources/public/js", (err, stdout, stderr) => {
if (stdout) process.stdout.write(stdout);
if (stderr) process.stderr.write(stderr);
});
});
},
},
],
在 Node.js 而不是 shell 中编写插件,OS 兼容性应该没有问题。
plugins: [
{
apply: (compiler) => {
compiler.hooks.afterEmit.tap("AfterEmitPlugin", () => {
...use node here.
});
},
},
],