0

I'm using angular-cli architecture for the initial setup of the app.

I want to import some of global css files into my index.html file. But as node_modules directory is outside of my src directory i'm not getting the accurate path and hence css is not applying.

I'm using path in following meaner,

I have tried without ../ also but it's also not working.

for ex.

<link href="node_modules/ng2-toastr/bundles/ng2-toastr.min.css" rel="stylesheet"/>

&&

<link href="../node_modules/ng2-toastr/bundles/ng2-toastr.min.css" rel="stylesheet"/>

But both the ways are not working.

Is anything wrong i'm doing?

Here is the app structure.

enter image description here

I'm using angular 2.2.1

Here is the error i'm getting

enter image description here

Thanks in advance

a better oliver
  • 26,330
  • 2
  • 58
  • 66
Pinank Lakhani
  • 1,109
  • 2
  • 11
  • 31
  • Have you [checked your console?](http://stackoverflow.com/documentation/javascript/185/getting-started-with-javascript/714/using-console-log) Are you getting a 404 error? Are you serving `node_modules` over your server? – Mike Cluck Dec 05 '16 at 14:33
  • Yes. I have updated question with screen – Pinank Lakhani Dec 05 '16 at 14:39
  • Maybe [this answer](http://stackoverflow.com/questions/37844334/add-the-css-from-the-node-modules-folder-using-angular-cli) will help you – Shaho Dec 05 '16 at 14:44
  • I'm not having the angular-cli-build.js file. You can see in screenshort. – Pinank Lakhani Dec 05 '16 at 14:59

1 Answers1

4

Check the documentation of angular CLI on how to install global libraraies,

you have to modify your angular-cli.json file to include css files in bundled style file not use directly in the HTML.

"styles": [
  "../node_modules/ng2-toastr/bundles/ng2-toastr.min.css"
]

Hope this helps!!

Madhu Ranjan
  • 17,334
  • 7
  • 60
  • 69