1

I'm on a trouble trying to use Alertify on my project. I'm using webpack encore from symfony 4.

I have isntalled using:

npm install alertifyjs --save

This is my app.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';

On the object that I'm trying to use you can see that I'm passing window, jQuery and alertify to the closure to use them inside, but just i'm getting this error:

GMExplotations.js:37 Uncaught ReferenceError: alertify is not defined at Object. (GMExplotations.js:37) at Object../assets/js/explotations/GMExplotations.js (app.js:327) at webpack_require (bootstrap:78) at Module. (app.js:1) at Module../assets/js/app.js (app.js:23) at webpack_require (bootstrap:78) at checkDeferredModules (bootstrap:45) at bootstrap:151 at bootstrap: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 is on my vendor~app.js but I can't find out why It can't find alertify, any idea?

Albeis
  • 1,544
  • 2
  • 17
  • 30

0 Answers0