Оповещение не найдено с помощью Webpack Encore Symfony 4 - PullRequest
1 голос
/ 28 мая 2019

У меня проблемы с попыткой использовать Alertify в моем проекте.Я использую Webpack Encore из Symfony 4.

Я установил:

npm install alertstifyss --save

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

    // any CSS you require will output into a single css file (app.css in this case)
import '../css/app.css';
import '../../node_modules/bootstrap/dist/css/bootstrap.css';
import '../../node_modules/admin-lte/bower_components/font-awesome/css/font-awesome.min.css';
import '../../node_modules/admin-lte/bower_components/Ionicons/css/ionicons.min.css';
import '../../node_modules/admin-lte/dist/css/AdminLTE.min.css';
import '../../node_modules/admin-lte/dist/css/skins/skin-blue.min.css';

const $ = require('jquery');
global.$ = global.jquery = $;

import 'bootstrap';
import '../../node_modules/admin-lte/bower_components/jquery-ui/jquery-ui.js';
import '../../node_modules/admin-lte/dist/js/adminlte.js';


const alertify = require('alertifyjs');
global.alertify = alertify;
// Custom js
import './dashboard/GMDashboard.js';
import './explotations/GMExplotations.js';

На объекте, который я пытаюсь использовать, вы можете видеть, что я передаю окно, jQuery и предупреждаю о закрытии, чтобы использовать их внутри, но просто я получаю эту ошибку:

GMExplotations.js: 37 Uncaught ReferenceError: alert не определено в Object.(GMExplotations.js: 37) в Object ../ assets / js / explotations / GMExplotations.js (app.js: 327) в webpack_require (начальная загрузка: 78) в Модуле.(app.js: 1) в Module ../ assets / js / app.js (app.js: 23) в webpack_require (начальная загрузка: 78) в checkDeferredModules (начальной загрузке: 45) в начальной загрузке: 151при начальной загрузке: 151

'use strict';

(function(window, $, alertify) {

    window.GMExplotations = function($wrapper) {
        console.log($wrapper);
        this.$wrapper = $wrapper;

        //TODO: Bind events

        // App Init
        this.init();
    };

    $.extend(window.GMExplotations.prototype, {

        _selectors: {

        },

        init: function() {
            console.log('Alertify test');
            alertify
                .alert("This is an alert dialog.", function(){
                    alertify.message('OK');
                });
        },

    });

    let ExplotationsWrapper = $('#explotations-table');

    if (ExplotationsWrapper.length > 0) {
        let GM = new GMExplotations(ExplotationsWrapper);
    }

})(window, jQuery, alertify); <- Here fails

Alertifyjs есть у моего поставщика ~ app.js, но я не могу выяснить, почему он не может найти alerttify, любая идея?

...