How can I create "web" and "node" versions of a package at the same time using Webpack?

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

+2


source to share


2 answers


I think the easiest way is to just create two config, one with target: "node"

and the other target: "web"

in config, and run them as$ webpack && webpack --config webpack.config.web.js



+2


source


You can create multiple config objects in the file webpack.config.js

:



const config1 = {
  target: 'web',
  ...
}
const config2 = {
  target: 'node',
  ...
}

export default [config1, config2]

      

0


source







All Articles