• grazianodev

    (@grazianodev)


    Hi,

    I would like to use Favorites in combination with Webpack, so I’ve unchecked the “Output Plugin Javascript” option, copied the code it appeared, pasted it in a Bookmarks.js file I’ve created and finally imported that file in my main.js, like so:

    import './modules/Bookmarks';

    But I get two errors:
    1) Uncaught ReferenceError: favorites_data is not defined;
    2) Favorites.Factory is not a constructor

    I also noticed no CDATA for the plugin is added to the page.

    I would really appreciate some help!

Viewing 1 replies (of 1 total)
  • Thread Starter grazianodev

    (@grazianodev)

    After further investigating, I’ve noticed that these lines of code from the plugin’s original file:

    jQuery(document).ready(function(){
        new Favorites.Factory;
    });

    become:

    jQuery(document).ready(function(){
        new Favorites.Factory();
    });

    in the file Webpack generates. Note the extra brackets appended after Factory. I guess this could explain the second error.

    I have no idea why Webpack would add those brackets, but is there a way I can rewrite that line of code in a way that Webpack would have no problem with, hopefully?

    I’m sorry but I’m really no Javascript expert.

Viewing 1 replies (of 1 total)
  • The topic ‘Using Favorites with Webpack’ is closed to new replies.