Skip to content

Instantly share code, notes, and snippets.

@ryanseddon
Last active August 29, 2015 14:22
Show Gist options
  • Select an option

  • Save ryanseddon/d2a6fdc0c38819d6b3ee to your computer and use it in GitHub Desktop.

Select an option

Save ryanseddon/d2a6fdc0c38819d6b3ee to your computer and use it in GitHub Desktop.
Webpack and css npm packages

Importing CSS packages via npm

If I have a package from npm let's say inuit-starter-kit which is a shell package that has its own dependencies. So all the packages I want to import exist in inuit-starter-kit/node_modules/{package}/{package}.scss.

Webpack

Webpack is configured to run all .scss files through sass-loader and then css-loader.

My entry file main.scss @imports all the deps using ~ to make sure it looks in node_modules

@import "~inuit-defaults";

@import "~inuit-functions";
@import "~inuit-mixins";

@import "~inuit-normalize";
@import "~inuit-box-sizing";

@import "~inuit-page";

Doesn't work?

It makes sense this doesn't work as how can npm know to look inside the shell package to know these are dependencies of it that I want to include.

Am I missing something?

Surely people have hit this before am I doing something stupid?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment