0

I have a fresh Laravel 5.8 installation and I would like to include the js modules from MDBootstrap.

In my bootstrap.js file I have:

require('./mdb/modules');

The ./mdb/modules.js file has:

exports.modules = [
  './js/_intro-mdb-pro.js',
  './js/scrolling-navbar.js',
  './js/vendor/jquery.easing.js',
  './js/vendor/velocity.js',
  './js/vendor/chart.js',
  './js/vendor/wow.js',
  ... 30 more
];

The compilation works ok, but of course, it doesn't take any effect from these modules include.

I don't know how to include all of them at once as they are not looking like a regular module so I can import like 'import * from 'my-module'

I also tried the ES6 way:

import * as MDBootstrap from './mdb/modules';

but I got the same result: successful compilation without including them into the compiled js file.

The content of these 'modules' doesn't seem to look like a normal module where we export default {} or some other functions or variables. It looks like:

//mdb/js/scrolling-navbar.js
"use strict";

(function ($) {
   var SCROLLING_NAVBAR_OFFSET_TOP = 50;
   $(window).on('scroll', function () {
      var $navbar = $('.navbar');

      if ($navbar.length) {
         if ($navbar.offset().top > SCROLLING_NAVBAR_OFFSET_TOP) {
            $('.scrolling-navbar').addClass('top-nav-collapse');
         } else {
            $('.scrolling-navbar').removeClass('top-nav-collapse');
         }
      }
   });
})(jQuery);

Even 'exports.modules = [..]' is not familiar to me. I know about 'module.export = ...' but this 'exports' looks like it's a Node.js object.

I know there's also another method to include the dist version of the plugin. I also tried it, but I got some errors: 'Identifier '_classCallCheck' has already been declared'. I looked deeper and I found that actually many of those files are declaring the '_classCallCheck' function and of course that it a redeclare error. Maybe I can refer to this particular error directly to them (MDBootstrap).

So here I am, trying to include and use these modules/files in my Laravel project without success. Any help is appreciated.

robe007
  • 3,523
  • 4
  • 33
  • 59
Spidey
  • 655
  • 1
  • 6
  • 20

0 Answers0