Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 5 and Webpack -- Do I REALLY need it?

I can't figure it out. I use the Angular-CLI to generate my project. when I use ng serve, it defently works great, also the ng build --prod.

Why do I need to eject or change the webpack file? is the DEFAULT webpack configuration is enough for production ? if not, what will I need to add for example (maybe translate (i18))?

In which way I need to treat webpack in my developing workflow ?

like image 992
noririco Avatar asked Jan 29 '18 10:01

noririco


People also ask

Is webpack necessary for Angular?

Usually, webpack is hidden behind the Angular command-line tool. But in some cases, it may be necessary to tweak the configuration of webpack when building an Angular application.

What is the difference between Angular CLI and webpack?

Webpack is a module bundler and task runner. Angular CLI is a command line interface that bundles some of the techniques mentioned above. Under the hood it uses Webpack. It is easy to create an application that works out of the box.

Does Angular 11 use webpack?

Link to this section. Yes you can use webpack 5 with Angular 11, but there are 2 things you need to keep in mind: This can be used if you are using yarn. Webpack 5 support is still experimental, so not suggested for production.

Does angular 12 support Webpack 5?

I updated to Angular 12 yesterday which uses Webpack 5. In the v11 update we added experimental support for Webpack 5. Today, we’re happy to announce that we’re releasing a production ready version of Webpack 5 support in Angular.

How to enable custom Webpack configurations in angular?

To enable custom webpack configurations, open the angular.json configuration file. Locate the line "builder": "@angular-devkit/build-angular:browser" inside the architect.build section. Replace it with the following lines. "builder": "@angular-builders/custom-webpack:browser", Now, inside architect.build.options add the following property.

What is Webpack and why should you learn it?

Learning about webpack is one of the major hurdles to getting up and running with modern JavaScript frameworks like React and Angular. The nice folks on the Angular team wanted to make it easier for people to start using Angular. They did this by embedding webpack in the Angular CLI.

Will This article work with angular 2/angular 4?

This article was for Angular 2/Angular 4. It will not work with the latest versions of Angular or Webpack The dynamic web applications usually have lots of javascript files. These files are either created by you or it could be third party libraries like jquery/bootstrap etc. We include these in our index.html file using <script> tag.


1 Answers

I'm currently migrating a large project from angularJS to angular 5. And i'm facing with the dilemma whether to choose angular cli or go with plain webpack.

If your project does not need any special configurations and is generally straight forward, stick with angular cli which handles all the webpack configurations for you.

In your eyes webpack does not exist, you only have the tools and configurations given to you by angular cli team. currently they are yusing webpack, but it might change in the future.

If you suspect you might have not 'out of the box' solutions for your build process, eject your cli and start managing webpack configurations on your own.

like image 116
Benny Afriat Avatar answered Sep 20 '22 04:09

Benny Afriat