Webpack batch require of all AngularJS resources in a directory and its subdirectories
JavaScript CSS
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
test
.gitignore
LICENSE
README.md
index.js
karma.conf.js
package.json
tests.webpack.config.js

README.md

webpack-angular-resource-plugin

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.

Installation

npm install webpack-angular-resource-plugin --save-dev

Usage Example

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.

License

MIT (http://www.opensource.org/licenses/mit-license.php)