How to use main.js in Sage 9

Hi everyone,

I’ve been trying to put together a site with Sage 9, and I can’t for the life of me figure out how to add jQuery into the main.js scripts file. It has changed since Sage 8, and the build fails with “npm run build” when I directly add jQuery there. Below is what the page specific Sage 9 main.js looks like now.

Do I need to specify “Init” and “Finalize” somehow? My guess is yes, but I’m not clear on how to do that.

const routes = {
// All pages
common,
// Home page
home,
// About us page, note the change from about-us to aboutUs.
aboutUs,
};

Thanks!

1 Like

https://github.com/roots/sage/tree/master/assets/scripts/routes

2 Likes

Oh… I get it. I saw those, but didn’t connect the dots that I had to put the javascript inside of THOSE files, and not in the main.js file anymore.

Thanks so much!

:thumbsup:

20 damn chars

Bump. Link is broken and the Sage 9 docs don’t describe main.js yet … But the answer is there in the next post. Add your JS to to the .js files in the scripts/routes/file.js files :smiley: