2

This is from my Gruntfile:

requirejs: {
  compile: {
    options: {
      almond: true,
      optimize: 'closure',
      baseUrl: '<%= cfg.src %>/scripts',
      mainConfigFile: '<%= cfg.src %>/scripts/config.js',
      out: '<%= cfg.staticDist %>/scripts/all.js',
      deps: ['app', 'config', 'bluebird', 'jquery']
    }
  }
},

When I set optimize to closure, grunt-requirejs writes this to console:

Running "requirejs:compile" (requirejs) task
>> Error: Error: optimizer with name of "closure" not found for this environment
>>     at Object.optimize.js (/Users/dan/Documents/Projects/test/node_modules/grunt-requirejs/node_modules/requirejs/bin/r.js:24632:27)

Does grunt-requirejs support optimising with Closure Compiler? Where do I need to put it?

Dan Abramov
  • 264,556
  • 84
  • 409
  • 511

2 Answers2

1

I think what you want to do here is that you want to use the more updated grunt-contrib-requirejs without optimization.

Then use a grunt task like grunt-closure-tools to optimize the combined files.

I found a user on GitHub that has success with this.

Allan Kimmer Jensen
  • 4,333
  • 2
  • 31
  • 53
1

As Allan said and asciidisco confirmed:

We got rid of that. Caused too many troubles. Also, r.js only supports that (correct me if I´m wrong) if you´re in a rhino environment & because we are node only, we stick with uglify.

If you really wan't to use Closure Compiler, I recommend to run the task with no minification & apply a task such as grunt-closure-compiler to the optimised files later in your process.

Community
  • 1
  • 1
Dan Abramov
  • 264,556
  • 84
  • 409
  • 511