Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Webpack with angular 1.x and ES5

Tags:

After reading hundreds of lines about browserify vs webpack and several how to of both I decided to go for webpack. The main reason it's because I liked the idea of bundling everything into a js file.

I have an angular project already working and I want to refactor it for webpack. The problem? My project is using angular 1.4.7, ng-animate and plain javascript (ES5) and all the tutorials and manuals are for ES6. I don't want to refactor my project so much. What's the way to go? I would like an example of each angular module : factory, directive, controller and so on. Many thanks

like image 293
Danielo515 Avatar asked Oct 31 '15 21:10

Danielo515


1 Answers

I typically have a feature.module.js file which has my module definition and requires all of the directives / services contained within the module. Also has the external dependancies.

/* module.js */  angular.module('my.module',['dependancy1', 'dependancy2']);    //External libraries  require('./dependancy1.module.js');  require('./dependancy2.module.js');    //Internal components  require('./thing.directive');  require('./thing.service';   

         /* service.js */  angular.module('my.module')      .directive('yourDir', function myDir(){...});                                                                                          
like image 65
Ryan Avatar answered Sep 19 '22 09:09

Ryan