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!
Here's how: http://requirejs.org/docs/optimization.html#empty
In a build profile:
({
baseUrl: ".",
name: "main",
out: "main-built.js",
paths: {
jquery: "empty:"
}
})
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.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With