Проблема с webpack, потому что datepicker () не является функцией - PullRequest
0 голосов
/ 10 января 2020

jquery -ui виджет Datepicker не работает с Encore webpack, потому что он не является функцией:

TypeError: $(...).datepicker is not a function

Вот мое приложение. js:

global.$ = global.jQuery = $;
require('jquery-ui');
require('popper.js');
require('bootstrap');
require('bootstrap-table');
require('select2');
require('../lib/jquery-switchbutton/jquery.switchButton.js');
require('./bootstrap3-typeahead.min.js');

и webpack config:

var Encore = require('@symfony/webpack-encore');
var path = require('path');

Encore
    .setOutputPath('public/build/')
    .setPublicPath('/build')
    .addEntry('app', './assets/js/app.js')
    .splitEntryChunks()
    .enableSingleRuntimeChunk()
    .cleanupOutputBeforeBuild()
    .enableBuildNotifications()
    .enableSourceMaps(!Encore.isProduction())
    .enableVersioning(Encore.isProduction())
    .autoProvideVariables({
        $: "jquery",
        jQuery: "jquery",
        Popper: ['popper.js', 'default']
    });

var config = Encore.getWebpackConfig();
config.resolve.alias = {
    jquery: path.join(__dirname, 'node_modules/jquery/dist/jquery')
};
module.exports = config;

Есть какие-нибудь решения? Спасибо!

...