Stylus fail build when you try import file which not exist. In some cases it's bad behavior. This plugin solve this problem.
You can install through npm as such: npm install stylus-import-if-exist
You can include stylus-import-if-exist as a normal stylus plugin. Example:
var stylus = require('stylus');
var importIfExist = require('stylus-import-if-exist');
stylus(css)
.use(importIfExist())
.render(function(err, output){
console.log(output);
});
You should replace all your @import
with import()
. For example, instead use @import 'example'
you should use import(example)
. If file exist, it will be imported; if not – nothing will happen.