2

Please is it advisable and best practice to use bower components within my angular CLI project(angular4) with webpack when the project is already build on node modules.

Lekens
  • 1,823
  • 17
  • 31

3 Answers3

2

Bower

We'll use Bower for our front-end dependencies. Angular CLI does not install and configure Bower automatically so we'll have to add it to our projects again.

Installing Bower

You should already have Bower installed on your own machine since our curriculum has used it for the past several weeks. You can double-check by running the following command:

$ npm list -g bower

If you do not receive a version number, you'll need to install bower globally using the following command:

$ npm install bower -g

Initializing Bower

In our project directory, we can initialize Bower with the following command

$ bower init

You will be prompted with a series of questions about your project. You can simply press Enter for each to accept the default value.

This will add a new bower.json file to your directory:

{
 "name": "online-store",
 "description": "",
 "main": "",
 "authors": [
   "Epicodus Student <hi@epicodus.com>"
 ],
 "license": "MIT",
 "homepage": "",
 "ignore": [
 "**/.*",
 "node_modules",
 "bower_components",
 "test",
 "tests"
]
}

.gitignore

We'll also want to include /bower_components under the #dependencies section. (We'll install Bower in just a moment). Make sure to do this now:

# dependencies
/node_modules
/bower_components

For more details: https://www.learnhowtoprogram.com/javascript/angular-extended/angular-cli-bower-setup

Hulk
  • 97
  • 1
  • 11
1

I would advise against it. You can find pretty much everything you need as an npm package these days.

Even on the Bower.io website they are basically saying to not use it anymore for new projects.

Andrei Matracaru
  • 3,511
  • 1
  • 25
  • 29
-2

Here you can find guidelines to setup bower into an Angular CLI-generated application.

Angular CLI - Bower setup

Hulk
  • 97
  • 1
  • 11