Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using almond with grunt-contrib-requirejs

I'm trying to set up a gruntfile that utilizes requirejs and almond. The docs suggest it should be really easy, and following their lead, I tried:

requirejs: {
  compile: {
    options: {
      baseUrl: "tmp",
      mainConfigFile: "tmp/main.js",
      name: "../bower_components/almond/almond",
      out: "tmp/<%= pkg.name %>.js"
    }
  }
}

Unfortunately, this approach compiles almond.js rather than my actual source. Am I getting something wrong? How do I automate almond along with requirejs?

like image 254
nullnullnull Avatar asked Feb 20 '14 00:02

nullnullnull


1 Answers

The trick is to use include:

requirejs: {
  compile: {
    options: {
      baseUrl: "tmp",
      mainConfigFile: "tmp/main.js",
      include: "main",
      name: "../bower_components/almond/almond",
      out: "tmp/<%= pkg.name %>.js"
    }
  }
}

Where main is the require.js file you would typically call like so:

<script data-main="scripts/main" src="scripts/require.js"></script>
like image 192
nullnullnull Avatar answered Oct 30 '22 13:10

nullnullnull