Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Requirejs output to single file excluding jQuery not retaining dependency?

I'm using the requirejs optimizer to minify my modules into one single file for production. I want to however exclude jQuery from the file so it can be loaded separately from the actual application logic, how can I achieve this? I tried setting this up with the exclude and excludeShallow parameters, but when I run the page I get the following error:

Uncaught ReferenceError: jQuery is not defined app.min.js:14 (anonymous function) app.min.js:14

My grunt config for requirejs looks like this:

requirejs: {
        minify: {
            options: {
                baseUrl: 'js',
                mainConfigFile: 'js/main.js',
                name: 'main',
                out: 'js/app.min.js',
                excludeShallow: [
                    'jquery'
                ]
            }
        }
    }

Many thanks!

like image 642
user2129447 Avatar asked Mar 03 '13 18:03

user2129447


2 Answers

Here's how: http://requirejs.org/docs/optimization.html#empty

In a build profile:

({
    baseUrl: ".",
    name: "main",
    out: "main-built.js",
    paths: {
        jquery: "empty:"
    }
})
like image 162
Eric Johnson Avatar answered Nov 29 '22 23:11

Eric Johnson


Try capitalizing jQuery the same in app.min.js as in excludeShallow. I've run into similar problems before on *nix machines.

(Do you have app.min.js? That might help with figuring this out.)

like image 42
Chris Avatar answered Nov 30 '22 00:11

Chris