I have structure like:
- app
- scripts
- libs
- jquery.js
- bootstrap.js
- moment.js
- app.js
- vendor.js
- common.js
- app.config.js
- main.js #require config
- libs
- scripts
Note vendor.js is just a file that includes all files under libs. Ex
//vendor.js
define(['jquery','bootstrap', 'moment'], function(){});
Just to list out the dependencies:
app.js
depends oncommon.js
andapp.config.js
common.js
depends onvendor.js
app.config.js
depends onmoment.js
What I'm trying to do is run the grunt requirejs command to create a vendor.js
file with all files under libs/
and a app.js
with the rest of the files not included in vendor.js
.
Here is what my requirejs options looks like:
module.exports = function (grunt) {
'use strict';
var config = {
dist: {
options: {
appDir: 'app/',
baseUrl: './scripts',
mainConfigFile: 'app/scripts/main.js',
dir: 'dist/scripts/',
modules: [
{ name: 'vendor'},
{ name: 'app', exclude: ['vendor'] }
]
}
}
};
grunt.config('requirejs', config);
};
What I get from running the above is the following build.txt
scripts/vendor.js
----------------
scripts/libs/jquery.js
scripts/libs/bootstrap.js
scripts/libs/moment.js
scripts/app.js
scripts/vendor.js
scripts/common.js
scripts/app.config.js
scripts/app.js
----------------
As you can see all the files are just appended to vendor.js
and not app.js
. I would expect vendor.js to include vendor.js
and its dependencies. And app.js
to include the rest since vendor
is excluded.
I've tried numerous combination and still a nogo here.