I am using require.js and r.js for the first time and i have nearly got it sorted however after i have built the app with r.js and uploaded to the server jquery is missing.
infact it is looking for jquery.js which is not on the server (as i was hoping it would still use the cdn as in my original require config).
1) should i include jquery and not load from a cdn? this makes me a little nervous as i thought it was always better to load jquery from a cdn. or should i be loading jquery in another call?
2) am i doing something wrong and jquery cdn should be loaded?
Could someone point me in the right direction to why jquery is not loading? i think i have followed all the configs correctly when using a cdn with r.js
heres my setup
common.js
require.config({
baseUrl: 'js/',
enforceDefine : true,
paths: {
'jquery': ['//code.jquery.com/jquery-1.11.0.min','/js/lib/jquery-1.11.0.min'],
'modernizr':'lib/modernizr.2.8.2',
'bootstrap':'lib/bootstrap.min.amd',
'safeBrowsing':'lib/safe.browsing.amd',
'owl':'lib/owl.carousel.min.amd',
'placeholder':'lib/placeholder.amd',
'easyPieChart':'lib/easyPieChart.amd',
'jqueryEasing':'lib/jquery.easing.amd',
'infoBubble':'lib/infobubble.amd',
'async':'lib/require/async',
'font':'lib/require/font',
'goog':'lib/require/goog',
'image':'lib/require/image',
'json':'lib/require/json',
'noext':'lib/require/noext',
'mdown':'lib/require/mdown',
'propertyParser':'lib/require/propertyParser',
'blueImpGallery': 'lib/blueimpGallery/jquery.blueimp-gallery'
},
priority: ['jquery'],
shim: {
'jquery': {
exports: '$'
},
'blueImpGallery' : {
exports : 'jquery'
},
}
});
main.js
define(['jquery','modernizr','bootstrap','safeBrowsing','owl','blueImpGallery','infoBubble'],function($){
console.log('foo bar');
});
build.js
({
mainConfigFile : "../js/common.js",
appDir: "../",
baseUrl: "js",
dir: "../../code-build/",
removeCombined: true,
findNestedDependencies: true,
optimize: "uglify2",
optimizeCss: "standard",
paths: {
'jquery': "empty:"
},
modules: [
{
name: "main",
exclude: ['jquery']
}
],
wrapShim: 'true',
generateSourceMaps: true,
preserveLicenseComments: false,
fileExclusionRegExp: /^admin$|.psd$|git-ftp|build|testnoise.sublime-project|testnoise.sublime-workspace/
})
Example link: http://test.noise.agency/require.test.php