Adding custom JS file and Grunt

Hey there. In my projects I normally have a theme-scripts.js file I use for specific stuff.

I’m using grunt, but my knowledge of grunt is minimal. When I added the file, added code to it, grunt complies fine, but the code isn’t being ran obviously.

So my question is this: Do I have to enqueue this script manually within roots lib/scripts or is there a way to make it auto minify into scripts.min.js using grunt?

Thanks.

Have you tried using the routing setup in _main.js? It’s where all the theme specific code should go.
If you want Grunt to uglify a script, either put it in assets/js/plugins (most suitable for plugins), prefix it with an underscore or manually add it to the Grunt file.

Wasn’t aware of _main.js’s routing. Thanks, good to go now.

Hey there, just starting to work with the new features of roots 6.5.0 like Grunt (all these things are new for me as my initial background is web/graphic design, but I’ve been working with Roots for my projects during more than a year now, but the new things in 6.5.0 seemed too much developer friendly to me… Finally, thanks to your superb tutorials in Roots website I think I’ve started to scratch what all this new things are about - - you’re awesome, guys!)
Concerning to the thread, I was asking me how does _main.js works as it’s the first time I’ve seen this kind of js routing file, are you planning on make an article in Roots blog, similar to the introductory ones to grunt, etc? Or maybe you could explain a bit how it works?
Thank you very much in advance!

Did you read through the original article by Paul Irish?

Thank you Foxaii, definitely will check it. First time I hear about ‘DOM-based routing’, my fault!