Skip to content

Webpack batch require of all AngularJS resources in a directory and its subdirectories

License

Notifications You must be signed in to change notification settings

liyutech/webpack-angular-resource-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)

About

Webpack batch require of all AngularJS resources in a directory and its subdirectories

Resources

License

Stars

Watchers

Forks

Packages

No packages published