Using almond with grunt-contrib-requirejs
Asked Answered
C

1

6

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?

Cinemascope answered 20/2, 2014 at 0:46 Comment(0)
C
11

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>
Cinemascope answered 20/2, 2014 at 2:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.