如何使用Webpack同时创建捆绑包的“网络”和“节点”版本? [英] How to simultaneously create both 'web' and 'node' versions of a bundle with Webpack?

查看:78
本文介绍了如何使用Webpack同时创建捆绑包的“网络”和“节点”版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用Webpack或Browserify一次性创建捆绑包的网络和节点版本?捆绑包的网络版本将在客户端上使用,同一捆绑包的节点版本将在服务器上使用以进行预渲染( 同构网络应用程序)。

Is there a way to create both 'web' and 'node' versions of a bundle with one go by using Webpack or Browserify? The 'web' version of the bundle will be used on a client, and 'node' version of the same bundle will be used on the server for pre-rendering ("isomorphic" web application).

推荐答案

我认为最简单的方法可能只是创建两个配置,一个配置为 target: node ,另一个 target: web ,然后像 $ webpack&& webpack --config webpack.config.web.js

I think the easiest way is probably just to create two configs, one with target: "node" and the other target: "web" in the configuration, and run them both like $ webpack && webpack --config webpack.config.web.js

这篇关于如何使用Webpack同时创建捆绑包的“网络”和“节点”版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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