S
S
Sergey2022-02-16 11:42:12
JavaScript
Sergey, 2022-02-16 11:42:12

How to include swiper in gulp using webpack?

In the gulp build, I use webpack to work with js, how do I connect swiper in this case? Tried via
import './libs/swiper-bundle.min', - doesn't work

const scripts = () => {
  return src('./src/js/main.js')
    .pipe(webpackStream({
      mode: isProd ? 'production' : 'development',
      output: {
        filename: 'main.js',
      },
      module: {
        rules: [{
          test: /\.m?js$/,
          exclude: /node_modules/,
          use: {
            loader: 'babel-loader',
            options: {
              presets: [
                ['@babel/preset-env', {
                  targets: "defaults"
                }]
              ]
            }
          }
        }]
      },
      devtool: !isProd ? 'source-map' : false
    }))
    .on('error', function (err) {
      console.error('WEBPACK ERROR', err);
      this.emit('end'); // Don't stop the rest of the task
    })
    .pipe(sourcemaps.init())
    .pipe(uglify().on('error', notify.onError()))
    .pipe(sourcemaps.write())
    .pipe(dest('./dist/js'))
    .pipe(browserSync.stream())
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question