B
B
blew_sweet2021-09-25 18:33:00
JavaScript
blew_sweet, 2021-09-25 18:33:00

Why is webpack with gulp not including node_modules?

I'm using gulp and webpack-stream for js, regular imports work on files, but node_modules doesn't. For some reason webpack is trying to look for node_modules in where the scripts
are Module not found: Error: Can't resolve 'swiper' in 'C:\projects\layout-in-HB\scripts'
Config:

gulp.task('js', function() {
    return gulp
        .src('scripts/app.js')
        .pipe(plumber())
        .pipe(webpackStream({

            output: {
                filename:'app.js',
            },
            module: {
                rules: [
                    {
                        test: /\.js$/,
                        exclude: /node_modules/,
                        use: {
                            loader: 'babel-loader',
                            options: {
                                presets: ['@babel/preset-env']
                            }
                        }
                    }
                ]
            },
            resolve:{
                modules: ['node_modules'],
                extensions: [".js"]
            },
            mode: 'development'
        }))
        .pipe(gulp.dest('dist/scripts'));
});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
imko, 2021-09-25
@imko

You have it written in plain text to exclude modules "exclude: /node_modules/,"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question