Reputation: 651
What's wrong with my webpack.config.js here, as it's failing to exclude node_modules. I've found similar posts about this issue with previous versions of webpack, but the fixes don't work as the syntax is different...
module.exports = {
context: __dirname,
entry: './src/index.js',
output: {
path: __dirname + '/public/assets/',
publicPath: '/assets/js/',
filename: 'bundle.js'
},
module: {
rules: [
{
test: /\.css$/,
include: /src/,
exclude: /node_modules/,
use: [
{loader: 'style-loader'},
{loader: 'css-loader'}
]
},
{
test: /\.ejs$/,
include: /src/,
exclude: /node_modules/,
use: [
{loader: 'ejs-simple-loader'}
]
},
{
test: /\.js$/,
include: /src/,
exclude: /node_modules/,
use: [
{loader: 'jshint-loader'}
]
},
{
test: /\.jsx$/,
include: /src/,
exclude: /node_modules/,
use: [
{loader: 'babel-loader'}
]
}
]
}
}
Upvotes: 2
Views: 1519
Reputation: 62
You are using rules that require the pre
value.
Your code should read:
module.exports = {
entry: "./foo.js",
output: {
filename: "./bar.js"
},
module: {
rules: [
{
test: /\.js$/,
enforce: 'pre', // updated value
exclude: /node_modules/,
use: [
{ loader: 'jshint-loader' }
]
}
]
}
};
Source: https://webpack.js.org/configuration/module/#ruleenforce
Upvotes: 2