We have a large-scale javascript application that we are trying to integrate and minimize using grunt-contrib-requirejs. We use the Aura structure. We use the gazebo to pull dependencies from other repositories into our main application.
Here is our structure
- app/
|
|_ main.js
|_ index.html
|_ css
|_ bower_components/
|_ core/
|_ widget1/
|_ main.js
|_ views/
|_ models/
|_ widget2/
|_ extension1/
|_ extension2/
|_ other third party libraries, etc
- Gruntfile.js
- bower.json
main.js:
requirejs.config({
shim: {
...
},
paths: {
'core': 'bower_components/core/app/main',
'aura': 'bower_components/aura/dist/',
'jquery': 'bower_components/jquery/jquery',
'backbone': ...,
... lots of other paths
}
});
define(['core', 'jquery', 'jqueryui'], function(core, $) {
});
Our current requirejs task :
requirejs: {
compile: {
options: {
mainConfigFile: 'app/main.js',
name: 'main',
include: ['bower_components/widget1/main', 'bower_components/widget2/main',
'bower_components/extension1/main', 'bower_components/extension2/main'],
exclude: ['jquery'],
insertRequire: ['main'],
out: 'dist/app.js'
}
}
}
This is consistent with our application / main and its dependencies, but when we try to run it, we get errors like:
GET http: //www.my-machine: 8080 / bower_components / underscore / underscore.js 404 (not found) although underscore is the dependency of many widgets that we turn on.
r.js , .
, :
# 2:
- dist/
|_ index.html
|_ css
|_ app.js
UPDATE
underscore , , - :
Failed to load resource: the server responded with a status of 404 (Not Found)
http://my-machine.com:8080/bower_components/core/app/main.js
, , :
define("bower_components/core/app/main.js", ["aura/aura", "bootstrap"], function(){
...
});
# 3
, ! core/app/main.js :
define(['aura', 'bootstrap'], function(Aura) {
...
});