Reputation: 819
I have a webpack.config with loaders like this:
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loaders: [ 'react-hot', 'babel-loader' ]
},
{
exclude: /node_modules/,
loader: 'eslint-loader',
test: /\.js$/
}
],
I exclude node_modules because other ways react-hot would get in trouble saying things like this
My problem is that: by excluding node_module, a private npm
package that needs babel-loader, would not be loaded into the bundle.
How can I manage excluding for each loader?
Upvotes: 1
Views: 483
Reputation: 1333
You can use the include
property for the loader instead of exclude
. For example:
loaders: [
{
test: /\.js$/,
include: [
path.resolve(__dirname, "app/src"),
// some module in node_modules folder
],
loaders: [ 'react-hot', 'babel-loader' ]
},
...
],
Note that both webpack
and react-hot-loader
recommend using include
over exclude
whenever possible.
Upvotes: 4