Today I wanted to break some stylus files out into their own module, and I wanted to be able to require a stylus module in the same way I would require a node module.
I tryed:
npm i my-styles-module
And then:
@require my my-styles-module
Which of course didn’t work, but there is a way.
As explained here, you can tell stylus other directories to look in for imports and requires, if it can’t find it in its working directory.
I’m using gulp to build my stylus, so all that was required was to add:
...
.pipe(stylus({
include: ['../node_modules']
})
...
And now stylus works just like node.