I've this dir structure:
webapp
├──static
│ ├── app
│ ├── config.js
│ ├── frontpage.js
│ ├── profile.js
│ └── utils.js
Gruntfile.js
And I'm trying to use grunt-contrib-requirejs to optimize my dependencies for profile
and frontpage
. Now my config.js looks like:
require.config({
{
baseUrl:"/static/app",
shim: {
bootstrap : { "deps" :['jquery'] } ,
velocity : { "deps" : ['jquery']}
},
paths: {
jquery: "../bower_components/jquery/dist/jquery.min",
bootstrap : "//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min",
requirejs: "../bower_components/requirejs/require",
handlebars: "../bower_components/handlebars/handlebars.min",
velocity: "../bower_components/velocity/velocity.min"
},
packages: []
});
I tried the following config for grunt-require-config
requirejs: {
compile: {
options: {
appDir: "static/app",
modules : [
{
name: "profile"
}
],
mainConfigFile: "./static/app/config.js",
optimize: "none",
dir: "./static/build/"
}
}
}
but I get this error:
Running "requirejs:compile" (requirejs) task
{ [Error: Error: ERROR: module path does not exist: /static/app/profile.js for module named: profile. Path is relative to: /webapp
[..]
which is strange, because that path is correct!
I can't find many examples of this around, can anyone help?
UPDATE:
All I needed was to adjust the baseUrl
in the Gruntfile.js and I removed appDir
. The baseUrl in the requirejs options is now the same as in the config.
requirejs: {
compile: {
options: {
baseUrl: "static/app",
/* modules : [
{
name: "profile"
},
{
name: "frontpage"
}
],*/
mainConfigFile: "./static/app/config.js",
optimize: "none",
dir: "./static/build/"
}
}
}