Coder Social home page Coder Social logo

grunt-requirejs's Introduction

grunt-requirejs Build Status

Optimize require.js based projects

Getting Started

If you haven't used grunt before, be sure to check out the Getting Started guide.

From the same directory as your project's Gruntfile and package.json, install this plugin with the following command:

npm install grunt-requirejs

Once that's done, add this line to your project's Gruntfile:

grunt.loadNpmTasks('grunt-requirejs');

Overview

Inside your Gruntfile.js file add a section named requirejs. This section specifies the options passed to RequireJS Optimizer.

Parameters

options object

This controls how this task (and its helpers) operate and should contain key:value pairs, see options below.

Options

For a full list of possible options, see the r.js example build file.

Config Example

Example require js optimizer config entry:

  requirejs: {
    compile: {
      options: {
        baseUrl: "path/to/base",
        mainConfigFile: "path/to/config.js",
        out: "path/to/optimized.js"
      }
    }
  }

There is no difference between declaring your require config in your Gruntfile and using a separate requirejs config file.

Note: Minification via Closure Compiler is not supported! You can, however, use grunt-closure-compiler as a separate build step after grunt-requirejs.

Almond

grunt-requirejs is capable of replacing require.js with almond.js automatically

For more infos please take a look at the Almond Integration document

Using custom r.js versions

grunt-requirejs lets you specify a custom r.js for your build

For more infos please take a look at the Using Custom r.js versions document

Using source maps

grunt-requirejs can generate sourcemaps when using the r.js v2.1.2 or higher

For more infos please take a look at the Using Source Maps document

Examples

There are some project & configuration examples to get you started:

Release History

Check the Changleog for more information

Contributing

If you like to file an issue or submit a pull request, please check the contributing guidelines

Contributors

Check the AUTHORS File for more information

Resources

License

Copyright (c) 2012 Sebastian Golasch Licensed under the MIT license.

grunt-requirejs's People

Contributors

airtonix avatar asciidisco avatar b-long avatar bernos avatar chrissrogers avatar cloudchen avatar drewlustro avatar existentialism avatar gaearon avatar indieisaconcept avatar josh-a-e avatar jzaefferer avatar kengotoda avatar lauripiispanen avatar mkuklis avatar nitinhayaran avatar phated avatar podgorniy avatar praveenkishor123 avatar rodneyrehm avatar sindresorhus avatar steveperrycreative avatar svnlto avatar tbassetto avatar tomfuertes avatar xdamman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

grunt-requirejs's Issues

grunt-contrib

Hi Sebastian.

You might familiar with grunt-contrib, an officially maintained collection of quality grunt tasks.

We're trying to reduce duplication and I was wondering if you would be willing to combine efforts?

@tkellen created the grunt-contrib-requirejs task which is pretty similar with the exception of Almond support.

If you agree, this would mean all of us working together to make one really good RequireJS under the grunt-contrib org while deprecating this one.

Cannot find module 'jsdom'

I followed the steps described on the getting started the error is rising when I type 'grunt' to compile the project:

user$ grunt
Loading "require.js" tasks and helpers...ERROR
Error: Cannot find module 'jsdom'

Am I doing something wrong?

Consider using multi-task

Consider using Grunt's built-in support for multi-tasks which is similar to you Dual Config.

The major difference is that the user is not tied to js or css as names.

For example, the user may want to use the following structure.

requirejs: {
  scripts: {
  },
  styles: {
  },
  prod: {
  }
}

-- nice grunt task, however

Grunt 0.4 Release

I'm posting this issue to let you know that we will be publishing Grunt 0.4 on Monday, February 18th.

If your plugin is not already Grunt 0.4 compatible, would you please consider updating it? For an overview of what's changed, please see our migration guide.

If you'd like to develop against the final version of Grunt before Monday, please specify "grunt": "0.4.0rc8" as a devDependency in your project. After Monday's release, you'll be able to use "grunt": "~0.4.0" to actually publish your plugin. If you depend on any plugins from the grunt-contrib series, please see our list of release candidates for compatible versions. All of these will be updated to final status when Grunt 0.4 is published.

Also, in an effort to reduce duplication of effort and fragmentation in the developer community, could you review the grunt-contrib series of plugins to see if any of your functionality overlaps significantly with them? Grunt-contrib is community maintained with 40+ contributors—we'd love to discuss any additions you'd like to make.

Finally, we're working on a new task format that doesn't depend on Grunt: it's called node-task. Once this is complete, there will be one more conversion, and then we'll never ask you to upgrade your plugins to support our changes again. Until that happens, thanks for bearing with us!

If you have any questions about how to proceed, please respond here, or join us in #grunt on irc.freenode.net.

Thanks, we really appreciate your work!

Using almond results in “define is not defined” (when using the compiled main.js)

As already stated in the title: When using the compiled main.js a Javascript ReferenceError occurs stating that “define is not defined” - earlier I used to delete all the compiled files and just use the compiled main-built.js, but this file isn't generated anymore.

Here are my gruntfile's (relevant) contents:

requirejs: {
    dist: {
        options: {
            almond: true,
            wrap: true,
            modules: [{name: 'main'}],
            mainConfigFile: "src/js/main.js",
            baseUrl: "src/js",
            dir: "tmp/js",
            inlineText: true,
            preserveLicenseComments: false
        }
    }
}

I'm not sure whether that's my fault (although this configuration used to work some weeks ago), so I asked for help on GitHub and Twitter too

sample project

Would it be possible to provide a sample project as part of the getting started documentation?

A simple hello world project might help with understanding the structure and dependencies for someone like myself trying to get up and running with grunt and requirejs.

thanks for your work on the plugin

Fintan

Add lodash custom build support

Add the possibility to include lodashs custom build support to the build process.
That means, start with the dev version of lodash & dismiss everything you don´t need using config options
during the build

Fix version dependencies

Not sure yet what the actual issue is, but having grunt-requirejs depend on requirejs ">=2.0.x" is a problem, as that allows npm to install pretty much every version, not just patch releases.

Same applies to grunt, which would very much break once 0.4 is out.

I've fixed that here: jzaefferer@8c6e10b

Cannot read property 'prototype' of undefined

I've just installed a virtual machine to debug this error, so it's running in a complete fresh install of Windows7 with node v.0.8.1 and git bash.

error message

Every time I try to run grunt with requirejs it throws that error, on the other hand if I remove the grunt.loadNpmTasks('grunt-requirejs'); line everything runs fine (apart the fact that I can't run requirejs obviously)

Don't use cheerio for almondify

Cause of a bug in the cheerio library (which exists already 6 months... cheeriojs/cheerio#62) we are unable to use admondify. It would be nice if you could use another library (jsdom) or method for replacing the old script tag. I have looked in your source code and it seems the most elegant way, but parsing the whole dom only for replacing the script tag and getting such errors is it not worth.

Error messages eaten by 0.3.0

I have a troublesome requirejs configuration which was causing errors on 0.2.13 (with the base folder replaced by [PROJECT_FOLDER] for brevity):

$node_modules/grunt/bin/grunt requirejs:visualTests
Running "requirejs:visualTests" (requirejs) task

[PROJECT_FOLDER]node_modules/grunt-requirejs/node_modules/requirejs/bin/r.js:14174
throw new Error(errorMsg);
^
Error: Error: ENOENT, no such file or directory '[PROJECT_FOLDER]src/test/visual/javascript/app/visual/app/VisualTestApplication.js'
In module tree:
app

at Object.fs.openSync (fs.js:338:18)

at build ([PROJECT_FOLDER]node_modules/grunt-requirejs/node_modules/requirejs/bin/r.js:14174:23)
at requirejs.optimize.runBuild ([PROJECT_FOLDER]node_modules/grunt-requirejs/node_modules/requirejs/bin/r.js:15472:30)
at Object.context.execCb ([PROJECT_FOLDER]node_modules/grunt-requirejs/node_modules/requirejs/bin/r.js:1692:33)
at Object.Module.check ([PROJECT_FOLDER]node_modules/grunt-requirejs/node_modules/requirejs/bin/r.js:948:51)
at Object.Module.enable.id ([PROJECT_FOLDER]node_modules/grunt-requirejs/node_modules/requirejs/bin/r.js:1181:34)
at g ([PROJECT_FOLDER]node_modules/grunt-requirejs/node_modules/requirejs/bin/r.js:233:23)
at Module.emit ([PROJECT_FOLDER]node_modules/grunt-requirejs/node_modules/requirejs/bin/r.js:1224:21)
at each ([PROJECT_FOLDER]node_modules/grunt-requirejs/node_modules/requirejs/bin/r.js:165:31)
at Object.Module.emit ([PROJECT_FOLDER]node_modules/grunt-requirejs/node_modules/requirejs/bin/r.js:1223:17)
at Object.Module.check ([PROJECT_FOLDER]node_modules/grunt-requirejs/node_modules/requirejs/bin/r.js:1002:30)

I updated to 0.3.0 in the hope of either fixing the issue or getting more helpful error messages but now the config just silently fails:

$node_modules/grunt/bin/grunt requirejs:visualTests
Running "requirejs:visualTests" (requirejs) task

I'm guessing this behaviour is unexpected? I've tried to track down where the error has occurred but haven't had any luck yet - it seems to be somewhere in r.js...

For reference, here's my config (which has some sort of a bug - probably related to paths):

{
    baseUrl: 'src/test/visual/javascript/app',
    appDir: '',
    paths: {
        text: '../../../javascript/libs/require.text',
        i18n: '../../../javascript/libs/require.i18n',
        moment: '../../../javascript/libs/moment'
    },
    wrap: true,
    insertRequire: ['app'],
    name: 'app',
    include: ['app'],
    out: 'dist/test/visual/javascript/app/app.min.js'
}

A similar but slightly simpler task which works fine:

{
    baseUrl: 'src/javascript/app',
    appDir: '',
    paths: {
        text: '../libs/require.text',
        i18n: '../libs/require.i18n',
        moment: '../libs/moment'
    },
    wrap: true,
    insertRequire: ['app'],
    name: 'app',
    include: ['app'],
    out: 'dist/javascript/app/app.min.js'
},

Add jquery custom build support

Add the possibility to include jquery custom build support to the build process.
That means, start with the dev version of jquery & dismiss everything you don´t need using config options
during the build. (Works only with jQuery >= 1.8.0)

Add backbone custom builder support

Add the possibility to include backbones custom build support to the build process.
That means, start with the dev version of backbone & dismiss everything you don´t need using config options
during the build

Error when trying to optimise CSS

I'm getting an error when I try to use grunt-requirejs to optimise my CSS. I have this in my Gruntfile.js:

requirejs: {
  css: {
    options: {
      optimizeCss: 'standard',
      cssIn: 'app/styles/main.css',
      out: 'app/styles/main.min.css'
    }
  }
}

When I run the build command I get an error:

grunt build

Running "requirejs:css" (requirejs) task
>> Error: TypeError: new path must be a string
>>     at Object.fs.renameSync (fs.js:439:18)
Warning: Task "requirejs:css" failed

I've struggled to find examples of people using grunt-requirejs to optimise their CSS, so I'm not even sure if I have used the options correctly.

Any ideas?

grunt-cli v0.1.6
grunt v0.4.0rc7
grunt-requirejs ~0.3.2

Comments go missing when replacing script tag

Following up from the discussion on Twitter, here's a better description of the problem and what I've found out about it.

In this specific case, the HTML file has something like this:

<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
  <head>

After passing through grunt-requirejs with the replaceRequireScript option turned on, we end up with the following:

<!DOCTYPE html>
<html class="no-js"><!--<![endif]--><head>

After having a look through the code and doing some debugging, I found what the cause of the issue is, but I'm not really sure of what a best solution would be for this case.

At the end of lib/replace.js, the contents of the modified file which has just been parsed through domino are written into the file:

// write out newly created file contents
grunt.file.write(file, getDoctype(document) + document.documentElement.outerHTML);

The problem is that when the code goes into domino, it's properly being parsed as a DOM tree, and in our original code there are actually 3 different start tags for . Apparently, domino uses the last one as the actual start of the node, and that's what it outputs when we get the outerHTML of the document.documentElement, which in a way, makes complete sense.

The innerHTML of document does have the whole thing, but without newlines around those comments, and it does still contain the doctype:

<!DOCTYPE html><!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]--><!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]--><!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]--><!--[if gt IE 8]><!--><html class="no-js"><!--<![endif]--><head>

I don't think it would be desirable to output the HTML like this from the plugin, so I thought it was probably better to have some brain storming around a potential better fix for this.

How would you get verbose output?

Hi,

I was wondering if there was a way to get output that is as verbose as:

node r.js -o app.build.js 

? The above shows which files were uglified and combined, etc.

I guess I could just run the above node command from a custom grunt task, but I like how your module allows app.build.js to be in the grunt init, but the only output I see is:

Running "requirejs" task
>> RequireJS optimizer started
>> RequireJS optimizer finished
Compressed size for module "main": 43734 bytes gzipped (148185 bytes minified).

Thanks!

Warn if src directory equals build target

To prevent users from wiping out their src project directories, warn if the src dir equals the dest dir. Create a flag to disable the checks, for users that are intentionally targeting the folder.

Can't find the dir value

Here is my project folder structure:

project
|--Gruntfile.js
|--build
|--public
|--|--js
|-----|--lib
|-----|--module
|-----|--main.js

my build config is in the Gruntfile.js

   requirejs: {
        compileProject: {
            baseUrl: 'js', 
            appDir: 'public', 
            dir: 'build',
            modules: [
                { name: 'main'}
            ],
            paths: {
                main: 'main',
                jquery: 'lib/jquery-1.10.0.min.js'
            }
        }
    }

but when I run it, the terminal tell me wrong:

Running "requirejs:compileProject" (requirejs) task
[Error: Error: Missing either an "out" or "dir" config value. If using "appDir"
for a full project optimization, use "dir". If you want to optimize to one file,
 use "out".

however I have already set the dir value, so what's wrong with my code?

Compiled build not running

I recently updated grunt-requirejs via NPM and my compiled JavaScript no longer runs. The main file loads but the callback passed to define is not executed. However, everything works fine when I don't compile and just load the modules dynamically. I've created a test project so you can hopefully reproduce the error.

Here's the compiled file found in build/js after running $ grunt

My directory structure:

node_modules
test.html
grunt.js
src/
src/js
src/js/test.js

Contents of test.js:

// Generated by CoffeeScript 1.4.0

define(function() {
  return console.log('loaded');
});

Contents of grunt.js:

// Generated by CoffeeScript 1.4.0

module.exports = function(grunt) {
  grunt.loadNpmTasks('grunt-requirejs');
  grunt.initConfig({
    requirejs: {
      compile: {
        options: {
          almond: true,
          modules: [
            {
              name: 'test'
            }
          ],
          dir: 'build',
          appDir: 'src',
          baseUrl: 'js',
          optimize: 'none'
        }
      }
    }
  });
  return grunt.registerTask('default', 'requirejs');
};

Contents of test.html:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8" />
        <title>Test</title>
        <script src="build/js/test.js"></script>
    </head>
    <body>
    </body>
</html>

Versions:

$ grunt -version
grunt v0.3.17

$ npm view grunt-requirejs version
0.3.1

almond integration

This is more of a support request then a bug report. I've got pretty far along, though can't get the almond integration working.

My config looks like this:

requirejs: {
    almond: true,
    replaceRequireScript: [{
        files: ['index.html'],
        module: '/js/main-built'
    }],
    baseUrl: "js",
    paths: {
        'hbs': 'libs/hbs',
        'Handlebars': 'libs/Handlebars',
        'Backbone': 'libs/backbone',
        'underscore': 'libs/underscore',
        'bootstrap': 'libs/bootstrap',
        'json2': 'libs/json2',
        'Rickshaw': 'libs/rickshaw',
        'validate': 'libs/jquery.validate'
    },
    hbs: {
        templateExtension : 'hbs',
        stylesDir : '/static/css/',
        disableI18n: true
    },
    modules: [{name: 'main'}],
    out: "js/main-built.js"
}

There are multiple issues:

  • replaceRequireScript with almond:true has no effect, even though it would still be useful in this setup
  • the module property of items in the replaceRequireScript array is ignored, though I'd like that to be used for the src-attribute in tasks/require.js:146
  • Once the above works, I end up with a main-built.js. When loading that, I get a script error about window.require being undefined. My main.js calls require. If I change that to use define, I don't get an error, but nothing is executed.

So close...

Can't find variable: define

The optimiser runs and concats all of my defined modules, with almond. However, nothing runs on the front-end because define is not available.

Here is my grunt config:

requirejs: {
        compile: {
            options: {
                almond: true,
                optimize: 'none',
                baseUrl: './client',
                out: './public/js/build.js',
                include: ['main'],
                insertRequire: ['main']
            }
        }
    }

However, almond is wrapped in an anonymous function without actually making it available to the global scope. I'm not quire sure what the define('almond'... bit is doing?

(function () {
    [[almond stuff]]

    define("almond",[], function(){});
}());

[[my modules here]]

Adding wrap: true just wraps the whole thing in an anonymous function, so no effect there.

Can anyone help?

Grunt 0.4 Release

I'm posting this issue to let you know that we will be publishing Grunt 0.4 on Monday, February 18th.

If your plugin is not already Grunt 0.4 compatible, would you please consider updating it? For an overview of what's changed, please see our migration guide.

If you'd like to develop against the final version of Grunt before Monday, please specify "grunt": "0.4.0rc8" as a devDependency in your project. After Monday's release, you'll be able to use "grunt": "~0.4.0" to actually publish your plugin. If you depend on any plugins from the grunt-contrib series, please see our list of release candidates for compatible versions. All of these will be updated to final status when Grunt 0.4 is published.

Also, in an effort to reduce duplication of effort and fragmentation in the developer community, could you review the grunt-contrib series of plugins to see if any of your functionality overlaps significantly with them? Grunt-contrib is community maintained with 40+ contributors—we'd love to discuss any additions you'd like to make.

Finally, we're working on a new task format that doesn't depend on Grunt: it's called node-task. Once this is complete, there will be one more conversion, and then we'll never ask you to upgrade your plugins to support our changes again. Until that happens, thanks for bearing with us!

If you have any questions about how to proceed, please respond here, or join us in #grunt on irc.freenode.net.

Thanks, we really appreciate your work!

Almond Does Not Get Included With Multiple Modules

It looks like when you set almond to true, almond will be only added to the first module in your modules object. The other modules are just wrapped in a define.

Here is what my config looks like.

module.exports = function(grunt){
  grunt.initConfig({
    requirejs : {
      appDir: '../',
      almond: true,
      replaceRequireScript: [{
        files: ['../../button-build/green/index.html'],
        module: 'main'
      }],
      stubModules: ['cs'],
      modules: [{
        name: 'ConsumerBootstrap',
        exclude: ['coffee-script']
      },{
        name: 'ProviderBootstrap',
        exclude: ['coffee-script']
      }],
      dir: '../../button-build',
      baseUrl: 'coffee/',
      paths: {
        cs : 'libs/cs',
        'coffee-script' : 'libs/coffee-script'
      }
    }
  });

  grunt.loadNpmTasks('grunt-requirejs');
  grunt.registerTask('default', 'requirejs');
};```

npm issue installing grunt-requirejs 0.3.0

When upgrading from grunt-requirejs 2.1.2 to 0.3.0 on windows server 2008 R2, I get errors related to a post install script...

It looks like there are many new node module dependencies that did install (grunt-backbonebuilder, grunt-jquerybuilder, grunt-lodashbuilder, gzip-js, q, semver, temp)

  • The directories look ok, if I'm not planning on using Closure, do I need to worry about the below? I'm planning on using RequireJs with UglifyJS2.
  • Could you give a little more insight to the new module dependency updates related to the features from 2.1.2 to 0.3.0?

ERRORS from post install script
...
npm http 200 http://registry.npmjs.org/CSSwhat

[email protected] install D:\SVN\032413\jpmcjs\SCMBuild\node_modules\grunt-requirejs\node_modules\grunt-lodashbuilder\node
_modules\lodash
node build/post-install

[email protected] postinstall D:\SVN\032413\jpmcjs\SCMBuild\node_modules\grunt-requirejs\node_modules\grunt-lo
dashbuilder
node ./bin/post-install.js

Downloading the Closure Compiler...
npm http GET http://registry.npmjs.org/underscore
npm http GET http://registry.npmjs.org/combinations/0.1.0
npm http GET http://registry.npmjs.org/aug/0.0.5
npm http GET http://registry.npmjs.org/resistance/2.0.0alpha2
npm http 200 http://registry.npmjs.org/combinations/0.1.0
npm http GET http://registry.npmjs.org/combinations/-/combinations-0.1.0.tgz
npm http 200 http://registry.npmjs.org/resistance/2.0.0alpha2
npm http GET http://registry.npmjs.org/resistance/-/resistance-2.0.0alpha2.tgz
npm http 200 http://registry.npmjs.org/aug/0.0.5
npm http GET http://registry.npmjs.org/aug/-/aug-0.0.5.tgz
npm http 200 http://registry.npmjs.org/combinations/-/combinations-0.1.0.tgz
npm http 200 http://registry.npmjs.org/resistance/-/resistance-2.0.0alpha2.tgz
npm http 200 http://registry.npmjs.org/aug/-/aug-0.0.5.tgz
npm http 503 http://registry.npmjs.org/underscore
npm ERR! registry error parsing json
There was a problem installing the Closure Compiler. To manually install, run:

curl -H 'Accept: application/vnd.github.v3.raw' api.github.comhttps://api.github.com/repos/bestiejs/lodash/git/blobs/a27
87b470c577cee2404d186c562dd9835f779f5 | tar xvz -C 'D:\SVN\032413\jpmcjs\SCMBuild\node_modules\grunt-requirejs\node_modu
les\grunt-lodashbuilder\node_modules\lodash\vendor'
Downloading UglifyJS...
There was a problem installing UglifyJS. To manually install, run:

curl -H 'Accept: application/vnd.github.v3.raw' api.github.comhttps://api.github.com/repos/bestiejs/lodash/git/blobs/339
0b259e04829538e4d3635d12b317dd6103eca | tar xvz -C 'D:\SVN\032413\jpmcjs\SCMBuild\node_modules\grunt-requirejs\node_modu
les\grunt-lodashbuilder\node_modules\lodash\vendor'
[email protected] ./node_modules/grunt-requirejs
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected])
└── [email protected] ([email protected])

use the symlinked virtual path instead of systems real path

when im trying to build an app with dependencies linked relative out of an symlinked directory, r.js uses the current absolute system path instead of the virtual path.

Folder Structure:

/
|-libraries
|    |-jquery
|    |-bootstrap
|    |-requirejs
|-web
|   |-www_app1
|   |-www_app2
|       |- webroot  -> /coding/app/myapp
|       |- lib -> /libraries/
|-coding
|    |-app
|       |-myapp
|            |-mycode.js
|            |-Gruntfile.js

building out of "/web/www_app2/webroot/" with a path set to an relative upper folder like "../lib/" wont work, because "grunt-requirejs" or "r.js" resolve the current dir as a absolute system path.

"../" in "/web/www_app2/webroot/" would go straight to "/coding/app/" instead of "/web/www_app2/"

Error: Missing either a "name", "include" or "modules" option

Hi,
From a working grunt-requirejs 2.1.2 with Uglify, I'm trying to upgrade to 0.3.0.

I'm seeing this issue and at least one other is as well
https://groups.google.com/forum/?fromgroups=#!topic/requirejs/S89uHqWSbHU

From James Burke's reply.
' I really do not know though, best to ask at the grunt-requirejs project.'

Here's my output.
Running "requirejs:appDir" (requirejs) task
Error: Missing either a "name", "include" or "modules" option
at Function.build.createConfig (xxxx\node_modules\grunt-requirejs\node_modules\requirejs\bi
n\r.js:22690:19)

If I'm missing any upgrade steps, please let me know
Thanks,
Mark

Grunt failing on encountering requirejs

Grunt just fails on after running requirejs without throwing any errors (verbose also). I don't know if it is a bug but any help will be appreciated. I am using 0.3.0 and following require config:

"requirejs": {
"task": {
"baseUrl": REQUIRE_ASSETS,
"dir": REQUIRE_BUILD_DIR,
"paths": {
"jquery": "empty:",
"requireLib": "lib/require-2.0.1"
},
"removeCombined": true,
"modules": [
{
"name": "main",
"include": ["requireLib"]
}
],
"optimize": "uglify"
}

almond build and modules config

trying to build with almond and modules in my config. here's what I get when running my build:

Running "requirejs:js" (requirejs) task�
�RequireJS optimizer started
Including almond.js

Error: If the "modules" option is used, then there should be a "dir" option set and "out" should not be used since "out" is only for single file optimization output.
    at Function.build.createConfig (/Users/svenlito/Dropbox/Sites/...../node_modules/requirejs/bin/r.js:14833:19)

now If I leave out the modules bit, the task obviously fails...

Task won't run anymore on v0.3.0

Can't seem to get this working anymore after upgrading to v0.3.0. I've gone through the upgrade steps, but when I run the task it seems unable to find the grunt.util object:

Running "requirejs:compile" (requirejs) task
[D] Task source: /Users/adam/Repos/MyApp/node_modules/grunt-requirejs/tasks/require.js
[TypeError: Cannot read property '_' of undefined]
>> TypeError: Cannot read property '_' of undefined
Warning: Task "requirejs:compile" failed. Use --force to continue.

Aborted due to warnings.

I tried stripping my config down to only the very basics:

requirejs:
    compile:
        options:
            baseUrl: 'web/js/src'
            mainConfigFile: 'web/js/src/config.js'
            out: 'web/js/optimized.js'

I'm on node v0.8.15, grunt v0.4.0a.

Cannot find module 'grunt-jquerybuilder'

Just today ran into this. I'm on 0.3.3, having similar issue on 0.3.2 as well

➜ ui git:(dev) ✗ grunt requirejs
Running "requirejs:compile" (requirejs) task

Error: Cannot find module 'grunt-jquerybuilder'
Warning: Task "requirejs:compile" failed. Use --force to continue.

but 'grunt-jquerybuilder' seems to be installed

➜ ui git:(dev) ✗ npm list grunt-jquerybuilder
[email protected]
└─┬ [email protected]
└── [email protected]

error in npm installing "grunt-requirejs": "~0.3.1"

[email protected] postinstall /root/workspace/myproject/node_modules/grunt-requirejs/node_modules/grunt-lodashbuilder

node ./bin/post-install.js

module.js:340
throw err;
^
Error: Cannot find module '../node_modules/lodash/vendor/tar/tar.js'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:362:17)
at require (module.js:378:17)
at /root/workspace/myproject/node_modules/grunt-requirejs/node_modules/grunt-lodashbuilder/bin/post-install.js:14:13
at Object. (/root/workspace/myproject/node_modules/grunt-requirejs/node_modules/grunt-lodashbuilder/bin/post-install.js:166:2)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
npm ERR! [email protected] postinstall: node ./bin/post-install.js
npm ERR! sh "-c" "node ./bin/post-install.js" failed with 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is most likely a problem with the grunt-lodashbuilder package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node ./bin/post-install.js
npm ERR! You can get their info via:
npm ERR! npm owner ls grunt-lodashbuilder
npm ERR! There is likely additional logging output above.

npm ERR! System Linux 2.6.35-22-generic
npm ERR! command "node" "/usr/local/bin/npm" "install" "grunt-requirejs"
npm ERR! cwd /root/workspace/qsms_latest
npm ERR! node -v v0.8.14
npm ERR! npm -v 1.2.14
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /root/workspace/qsms_latest/npm-debug.log
npm ERR! not ok code 0

Does not work with closure compiler

Error: Error: optimizer with name of "closure" not found for this environment

  • this is all what I get. Specified optimize: "closure" in my config.

When will RequireJS 2.1.1 be released in grunt-requirejs?

Hi,

When will grunt-requirejs support requirejs 2.1.x? Is this coming with 0.2.14?

I see in the repository release history the latest version is 0.2.13, but I also see when looking at packages.json a reference to requirejs 2.1.x.

From npm, it looks like 0.2.14 is available, but it shows as still depending on requirejs 2.0.x.

npm view grunt-requirejs
npm http GET http://registry.npmjs.org/grunt-requirejs
npm http 200 http://registry.npmjs.org/grunt-requirejs

{ name: 'grunt-requirejs',
description: 'Using requirejs and almond with grunt',
'dist-tags': { latest: '0.2.14' },
...
dependencies:
{ grunt: '0.3.x',
requirejs: '2.0.x',
cheerio: '0.9.2',
almond: '0.2.x' },

Thanks much for the grunt-requirejs plugin,
Mark Saunders

Add hybrid minification

Use the r.js with ClosureCompiler only, uglifyjs only & then with a combinded (hybrid) minification afterwards.
Check which version is the smallest, dismiss the bigger files & leave the smallest.
Need to add a new config option 'hybrid' or smth.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.