Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include javascript in middleman 4?

I've been using Middleman for a while and it always used the Rails asset pipeline for including javascript and css. So to include a javascript module called "thing.js" in the same directory, you'd do:

//= require thing

But since Middleman 4, that seems to have changed and I can't find any documentation. The closest thing I can find is this page which shows me how to run an ember.js compilation: https://middlemanapp.com/advanced/external-pipeline/

So... if I want to load javascript files in Middleman now, do I have to roll my own build system? Or am I missing something?

like image 601
straffaren Avatar asked Feb 10 '16 11:02

straffaren


2 Answers

The easy answer was to include the middleman-sprockets gem. That way things will work like they used to.

Add this to your gemfile

gem 'middleman-sprockets', '~> 4.0.0.rc.1' 

Run bundle install.

You don't need to activate anything, the middleman-sprockets extension auto-activates

like image 82
Johan Halse Avatar answered Sep 27 '22 23:09

Johan Halse


The easy answer was to include the middleman-sprockets gem. That way things will work like they used to.

Add this to your gemfile

gem 'middleman-sprockets', '~> 4.0.0.rc.1' 

Run bundle install.

You don't need to activate anything, the middleman-sprockets extension auto-activates

like image 7
straffaren Avatar answered Nov 13 '22 10:11

straffaren