My webpack doesn't exclude node_modules folder, i followed this link
Webpack not excluding node_modules
I want to exclude node_modules folder from bundle, and have tried this older way to write: exclude: path.resolve(__dirname, 'node_modules') but still node_modules is imported
But after this exclude, I have error in console:
Uncaught ReferenceError: require is not defined
at Object.<anonymous> (out.fbd50140277b839fca03.js:1)
at E (out.fbd50140277b839fca03.js:1)
at t (out.fbd50140277b839fca03.js:1)
at Object.<anonymous> (out.fbd50140277b839fca03.js:1)
at Object.<anonymous> (out.fbd50140277b839fca03.js:1)
at E (out.fbd50140277b839fca03.js:1)
at t (out.fbd50140277b839fca03.js:1)
at Object.<anonymous> (out.fbd50140277b839fca03.js:1)
at E (out.fbd50140277b839fca03.js:1)
at out.fbd50140277b839fca03.js:1
And still node_modules folder is imported:
./node_modules/css-loader!./node_modules/sass-loader/lib/loader.js!./css/style.scss 1.36 KiB {0} [built]
[1] ./node_modules/css-loader/lib/url/escape.js 419 bytes {0} [built]
[2] ./node_modules/css-loader/lib/css-base.js 2.33 KiB {0} [built]
[3] ./images/furry.png 82 bytes {0} [built]
[4] ./images/coin.png 82 bytes {0} [
EDITED
This is weird, I have simply webpack and still it adds me over 30 positions! Look picture below:
Webpack.config.js
const path = require('path');
module.exports = {
entry: './js/app.js',
output: {
path: path.resolve(__dirname, 'js'),
filename: 'out.js',
},
devServer: {
contentBase: path.resolve(__dirname, 'js'),
port: 3000,
},
module: {
rules: [
{
test: path.resolve(__dirname, 'app.js'),
loader: 'babel-loader',
options: {
presets: ['env'],
},
exclude: path.resolve(__dirname, 'node_modules/')
}
]
}
}