In webpack server config file,
module: {
rules: [
{
test: /\.js?$/,
loader: "babel-loader",
exclude: /node_modules/,
}
]
}
exclude means do not compile those directories, in this case it is only node_modules. However there is also webpack-node-externals package.
const nodeWebExternals = require("webpack-node-externals");
externals: [nodeWebExternals()],
externals property inside module.exports object is going to tell webpack not to bundle any libraries into our output bundle on the server if that library exists inside the node-modules folder.
What is the difference between those two?