2

Running into an issue when I run the RequireJS optimizer... I have the following defined in my main config file:

require.config({

  config: {
    bootstrap: {
      autoload: true
    }
  },

  ... 
}

Then in my bootstrap.js file I do:

define(['module', 'app'], function (module, App) {
  'use strict';

  console.log(module.config().autoload);

  ...
});

But autoload is undefined :( The variable is available in the non-optimised version however.

I've tried this with other modules and other variables, but essentially no module config is being pushed through into the output file from Require's Optimizer.

Is this expected behaviour ?

cloakedninjas
  • 4,007
  • 2
  • 31
  • 45
  • Are you sure that bootstrap.js module have `bootstrap` name after build? Maybe it has some other id like `/bootstrap`? – ant_Ti Jul 14 '14 at 08:45

1 Answers1

0

I know this is a bit late, but I had spent close to half a day struggling with the same problem and finally found that this worked:

Apparently config.js file or the main config is compile time configuration and wont be part of run/build config. So the solution is to add the module config to the top of the main.js file using requirejs.config({}); (this is for the case that it already worked with config prior to compiling and minifying/uglifying).

eg:

at top of main.js add:

requirejs.config({
  config: {
    bootstrap: {
      autoload: true
    }
  }
};)
Arathi Sreekumar
  • 2,544
  • 1
  • 17
  • 28