Using Angular 1.x With ES6 and Webpack

1,028 阅读1分钟
原文链接: angular-tips.com

I know you’re all excited with Angular 2 and ES6, but that doesn’t mean we can’t use ES6 with Angular 1.x.

Today, I am going to present you my new workflow for Angular 1.x with ES6.

A brief introduction to Webpack

Webpack is a module bundler, what does that mean? Well, it basically take modules with dependencies and generate static assets to represent those modules.

So we could have a module like:

import foo from './foo';
foo.bar();

And if we process it with Webpack, it will take this my_module.js, retrieve its dependencies (foo.js) and generate a static file with both files.

So the idea with Webpack is: I tell you what the entry point is and you figure out the rest. For Angular applications, that is normally the file where we create our main module. So starting from that file, it starts pulling dependencies in (basically our entire application) and then it generates a bundle.js file which contains our application. There is no more need of creating hundred of