Recompiling Foundation

Wannabe contributor here. I’m trying to recompile Foundation’s plugins after a few tweaks. However, I can’t get the bower_components/foundation-sites/js/foundation.*.js files to compile into bower_components/foundation-sites/dist/js/plugins/foundation.*.js where apparently npm run build or foundation build looks when trying to build app.js. How do I perform that step, if I’m even looking in the right place?

I tried running webpack, seeing as that’s what the js files went through, but webpack 4.42.0 doesn’t accept the webpack.config.js that’s in foundation-sites (doesn’t like the ‘loaders’ entry, needs absolute dist paths, looks for js/entries/all.js which isn’t there, etc.)

Hi,

I do not currently understand what exactly you are trying to build. We do not use bower anymore (see the repo on GitHub).

The path references are for / from the original Git repo. You may have a very old version of Foundation Sites which uses webpack 3 and gulp 3.

I’m on 6.6.1, installed back in the times of - I think - v5, with foundation-cli, and updated recently.

I’m trying to build a modified version of one of the packaged plugins, so that it gets (if I got it right) webpacked and gulped finally into app.js.

And more specifically, to maybe go off topic a bit - I’m trying to figure out why in the world would foundation.util.triggers.js do this:

    if(document.readyState === "complete") {
      Triggers.Initializers.addSimpleListeners();
      Triggers.Initializers.addGlobalListeners();
    } else {
      $(window).on('load', () => {
        Triggers.Initializers.addSimpleListeners();
        Triggers.Initializers.addGlobalListeners();
      });
    }

… when in practice it means “if the document isn’t yet loaded, delay trigger inits until EVERYTHING is loaded” which sometimes takes over 10 seconds, with all the third-party tracking scripts and whatnot. Wasn’t this supposed to be “if the doc isn’t yet loaded, then wait for it to load”?

For now I modified it to use $() aka $(document).ready() by editing the compiled dist/*.js file, but the atrocity of this approach appals me.

The best is to clone the GitHub repo. I do not know your setup.

Correct, this has to do with AJAX and triggers which are too early initialized or called too multiple times. See the blame view on GitHub.

It seems you are on a very old version. This was changed about 2 years ago. See https://github.com/foundation/foundation-sites/blame/develop/js/foundation.util.triggers.js#L247