Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Already have a build.js file #41

Closed
CMCDragonkai opened this issue Sep 26, 2013 · 6 comments
Closed

Already have a build.js file #41

CMCDragonkai opened this issue Sep 26, 2013 · 6 comments

Comments

@CMCDragonkai
Copy link

If I already have a build.js file, is it possible to point to that file as the configuration rather than setting it up in the Gruntfile. Currently I'm using a shell operation and simply doing -o.

@gnrlwart
Copy link

You can read in the file and add it into your grunt config like this:

  var buildOptionsFile = grunt.file.read( buildOptionsPath );
  var buildOptions = eval( buildOptionsFile );
  // ... Adjust path settings appDir, baseUrl, and mainConfigFile if needed
  gruntConfig.requirejs = {
    compile : {
      options : buildOptions
    }
  };

Just make sure you do this before calling grunt.initConfig( gruntConfig ).

@dminkovsky
Copy link

This is sweet. Maybe link this from the README?

@tkellen
Copy link
Member

tkellen commented Mar 6, 2014

There is no need to do this incantation, r.js has a setting for specifying a build file: mainConfigFile

@dminkovsky
Copy link

Right, but if you're coming to grunt-contrib-requirejs from CLI usage, you already have a "build.js" file, which in turn is pointing to your mainConfigFile. You then have to replicate that build.js in your Gruntfile setup for grunt-contrib-requirejs.

@dminkovsky
Copy link

Which is no biggie, but all copy/pasting is annoying, especially when it might relate to build/deploy.

@Blasz
Copy link

Blasz commented Aug 14, 2014

mainConfigFile has to contain a requirejs({}), require({}), requirejs.config({}) or require.config({}).

build.js files should be JSON wrapped in parentheses and therefore cannot contain the require constructs that mainConfigFile needs.

Therefore mainConfigFile is not correct for specifying build profile files that you would pass via the command line to requireJS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants