Require all AngularJS modules for a Webpack project and return an array of the module names that can be used as dependencies of the main module. Can also batch require other resources such as style sheets and images.
npm install webpack-angular-resource-plugin --save-dev In the entry point where the main angular module is defined, such as index.js or app.js, require the plugin:var angularResourceUtil = require('webpack-angular-resource-plugin');
Require all css files under the current directory and its subdirectories:
var styleContext = require.context(".", true, /.css$/);
angularResourceUtil.requireAll(styleContext);
Define the main Angular module. Also require all files whose name end with .controller.js which contain submodules. Notice that the module names are returned as an array and passed to the factory method as dependencies of the main module:
var controllerContext = require.context('.', true, /\.controller\.js$/);
module.exports.default = angular.module('app', angularResourceUtil.requireAll(controllerContext));
To run the tests for this project, execute the following command from the terminal at the root directory of the project:npm test
For a more comprehensive example of how to use the plugin, check out this webpack-angular-template project.
MIT (http://www.opensource.org/licenses/mit-license.php)