How to add css file from npm package?

I installed to show map in my application. Leaflet demands adding css file to the project. How can I import it to Ionic 2 application ?

1 Like

You need to include <link rel="stylesheet" href="" /> (as stated here) Add this line in index.html just below the line where all the other stylesheets are imported. The file located in www folder of your project.

This needs internet connection to fetch the css file. If you want to make it work offline. Simply download the css file and link it in your html file. But i hope that your maps will always require a net connection so you can leave it like that.

I hope you have included the js file alredy

Thanks! I’ve just done that. I hope there is more elegant way to this than adding my assets by hand.

You can modify the gulpfile.js to include the resources of your npm package.

gulp.task('sass', function(){
  return buildSass({
    sassOptions: {
      includePaths: [

And then just import the style in app.core.scss:

@import "leaflet";

Take a look at and

The build process is documented in

Edit: Also take a look at Where should I put images? to include static images.

I use the following code in my gulpfile.js:

gulp.task('images', function() {
    return gulp.src([


runSequence(['images', 'sass', 'html', 'fonts', 'scripts'],

Hi your commands worked wonderfully of solving the above error. I have used the tsubik gulpfile and your above code but still getting an error in Ionic-2 latest beta of today. It is gives me the error:
Error: Couldn’t autodetect L.Icon.Default.imagePath, set it manually.

If i try to set it it tells me imagepath is not a property of Icon. Any ideas??

What version of leaflet were you in npm and typings?