问题
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).
回答1:
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
回答2:
You can create multiple config objects in webpack.config.js
file:
const config1 = {
target: 'web',
...
}
const config2 = {
target: 'node',
...
}
export default [config1, config2]
来源:https://stackoverflow.com/questions/26063480/how-to-simultaneously-create-both-web-and-node-versions-of-a-bundle-with-web