Using a ES6 js lib in Phoenix


I’m totally new to ES6 and struggling how to use an ES6 js lib on a specific page.

The frappe-gantt.min.js works, but I want to change some stuff here and there …

So I deleted the frappe-gantt.min.js, and copied the Gantt.js, Arrow.js & Bar.js to the /js folder
Now I want to use this lib on one specific page;

var gantt = new Gantt(document.querySelector("#gantt-container"), elements, { ... but the Gantt class seems undefined on the page .. how to pull this bastard in?


Depends on the javascript build system you are using. If you are using the phoenix-included-but-optional-Brunch then you can either add it as a global entry in the brunch config file, or you can include it (and be sure to reference it so it does not get optimized out) then require it from the page. All normal javascript stuff (front-end building), has nothing at all to do with Phoenix (back-end server) other than Phoenix just hosts out whatever’s in your priv/static. ^.^


have fixed it by calling var gantt = require(“js/Gantt.js”).default( params …