I use webpack for bundling the client side and want to use it for building node/npm library. I saw I can specify the target as node for this. From the doc,
"node" Compile for usage in a node.js-like environment (use require to load chunks)
But the problem is react.js is bundled in the compile output. I want only my source files and any dependencies listed in package.json to be included. I have specified react as peerDependency, like
"peerDependencies": {
"react": ">=0.13",
"react-tap-event-plugin": ">=0.1.3"
},
I also try defining react in externals expecting it may just create the symbol and not include the library itself, but it still includes react in compiled output.
target: "node",
externals: [{
'react' : 'React',
}]
so, is there a way to use webpack to bundle by server side / node code, but also to specify not to bundle some of the dependencies (which may be defined as peerDependencies or devDependencies)?
webpack.config.jsaddtarget: 'node'.