npm link doesn't play nicely with Sass imports #715
Labels
area: tooling
💓collab
a vibrant hub of collaboration
⭐️rep
an industry leading reputation
type: bug 🐞
It's currently not possible to
npm link
this repo into a project that imports our Sass files without addingsrc/
after@primer/css
in the import path. For instance:This works when you
npm install @primer/css
because we copysrc/*
up a level inscript/prepublish
. But if younpm link path/to/primer/css
, that script doesn't run,support/index.scss
doesn't exist because it lives insrc/
, and you have to change it your import path:This is not great. We have options, though!
Add
node_modules/@primer/css/src
to Sass import pathsThis is the simplest option and involves only updating our docs, but it's also kind of an ugly hack.
Move
src/*
up to/
in gitThis fixes the issue, but clutters the repo root with lots of directories, some of which contain SCSS files while others (
pages
,script
,bin
,lib
, etc.) don't. I prefer to silo off the style sources from other types of files, but I'm open to it if this doesn't bother anyone else.Symlink
src/*
to/
on installationWe might be able to detect one npm's automatic environment variables to determine if we're running "locally" and add those files to
.gitignore
so that they're not committed accidentally. I testednpm link
on my machine and it doesn't look like we can hook into it with alink
script inpackage.json
. Butinstall
runs automatically as part of linking, so we might be able to do it there.Sass custom importer sorcery?
Nope nope nopity nope. Don't even think about it.
The text was updated successfully, but these errors were encountered: