Reputation: 26075
I'm using Webpack for files meant to be ran in Node. I don't want to bundle any files in node_modules
. I just want Webpack to leave them as require('module')
. How can I do that?
Upvotes: 5
Views: 1680
Reputation: 765
Try using target: 'node'
in your webpack configuration. Although in general you would use externals
field to exclude some modules from the bundle. For example, webpack-node-externals uses externals
to do exactly what you need. It seems a bit stale, but I think you can check the sources and do something like that yourself if you don't want to depend on an unmaintained lib. Webpack documentation shows some code that does more or less the same.
Upvotes: 3