I am building an nw.js application using Webpack and Angular. I would like to achieve something that I saw and used in my other angular application from this template https://github.com/jakemmarsh/angularjs-gulp-browserify-boilerplate .
The following code is for organizing code and modules, and it does a great job. Each module has a _index.js file that contains the following:
var bulk = require('bulk-require'); module.exports = angular.module('app.services', []); bulk(__dirname, ['./**/!(*_index|*.spec).js']);
This exports the angular module, and then to the same directory each file simply requires it and continues to use it (not quite sure, but maybe the one that requires it should not be in the same directory):
var app = require('./_index'); app.controller('SomeCtrl', function...);
Now, to implement Webpack, I tried setting up this this example:
require.context("..", true, /^grunt-[^\/]+\/tasks/[^\/]+$/);
and this is my version
require.context(__dirname, true, /./**/!(*_index|*.spec).js/);
I am sure my regex is not applied correctly there, so I need your help on how to make this work.
On the other hand, I'm not sure how the template functions require the function, and what exactly it does. I believe that it includes all the files, since otherwise no other part of the application will know about them. So instead, including each directive, service, and controller manually, I would say that it does the job for you.
Help a lot :)