direictives/index.js:
module.exports = function(ngModule) { //register all the directives here require('./hello')(ngModule);};
directives/hello.js
module.exports = function(ngModule) { ngModule.directive('webHello', function() { return { restrict: 'E', scope: {}, templateUrl: 'directives/hello.html', controller: function() { var vm = this; vm.greeting = "Hello Webpack!"; }, controllerAs: 'vm' } })};
directives/hello.html:
{ {vm.greeting}}
app/index.js:
var angular = require('angular');var ngModule = angular.module('app', []); //require directives folder, then it will find index.js filerequire('./directives')(ngModule);console.log(ngModule);
app/index.html:
Webpack + AngularJS