A
A
Anton Shelestov2020-10-09 19:04:57
JavaScript
Anton Shelestov, 2020-10-09 19:04:57

I do not understand why select2 is not connected?

Hello!
Please tell me what I'm doing wrong. Gulp building script.js

project

import $ from 'jquery';
import select2 from 'select2';
import Swiper, {Scrollbar, Mousewheel, Navigation} from 'swiper';
Swiper.use([Scrollbar, Mousewheel, Navigation]);

window.onload = function () {
 $('.select2').select2();
});


Galp task:
module.exports = function script(cb) {
    return browserify({
        entries: [
            // 'src/scripts/select2.full.min.js',
            'src/scripts/scripts.js'
        ],
        transform: [
            babelify.configure({ presets: ['@babel/preset-env'] }),
        ],
    })
        .bundle()
        .pipe(source('scripts.js'))
        .pipe(buffer())
        .pipe(sourcemaps.init())
        .pipe(concat('scripts.js')) // Конкатенируем в один файл
        .pipe(terser())
        .pipe(sourcemaps.write())
        .pipe(rename({suffix: '.min'}))
        .pipe(gulp.dest('build/js'));
};


But after assembly, it gives an error that there is no selec2 ((What the hell does
5f808a15ebd0e366534462.jpeg

he need?) There are always some problems with him))

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