Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Clare A
Clare A
23,994 Points

How best to link normalize.css to my project when installing via npm?

I'm using GitHub to manage my javascript project files, npm for dependencies and webpack for the build. One of the dependencies is normalize.css.

My question is, what is best practice for linking normalize.css (or any other css package) to my project in this case?

After scouring stack overflow and some other resources, it seems my options are;

  • Use the link tag in my html header and point it to my /node_modules folder (not recommended)
  • Use a require() call in the javascript
  • Use @import in style blocks

Anyone have any recommendations?

Clare A
Clare A
23,994 Points

thanks Benjamin Babic! I'm just setting this up now i.e. importing the stylesheet from within my app.js entry file. For the file path, is it good practice to reference the node_modules directory? For example...

import './node_modules/<mypackage>/<mypackage>.css'

If not, how would you specify the file path?

1 Answer

Hi Clare, You are using bundler(in this case webpack) so I would go for and @import inside your prefered stylesheet(less, scss). You will avoid extra http request for the file, and webpack will take care of concatenating normalize with your other partial stylesheet files.