4 Stylus supports both literal __@import__ for CSS, as well as dynamic importing of other Stylus sheets.
8 Any filename with the extension `.css` will become a literal, for example:
12 will render to the literal css __@import__ shown below:
18 When using __@import__ without the `.css` extension, it is assumed to be a Stylus sheet, for example `@import "mixins/border-radius"`.
20 __@import__ works by iterating an array of directories, and seeing if this file lives in any of them, similar to node's `require.paths`. This array defaults to a single path which is derived from the `filename` option's dirname. So if your filename is `/tmp/testing/stylus/main.styl`, then import will look in `/tmp/testing/stylus/`.
22 __@import__ also supports index styles, meaning if you `@import blueprint`, it will resolve either `blueprint.styl` or `blueprint/index.styl`, useful for libraries to expose all of their features, but still allow a subset of the library to be imported. For example a common lib structure might be:
30 In the example below we set the `paths` options to provide additional paths to Stylus. Within `./test.styl` we could then `@import "mixins/border-radius"` or `@import "border-radius"` since `./mixins` is exposed to Stylus.
33 * Module dependencies.
36 var stylus = require('../')
37 , str = require('fs').readFileSync(__dirname + '/test.styl', 'utf8');
41 , __dirname + '/mixins'
45 .set('filename', __dirname + '/test.styl')
47 .render(function(err, css){
52 ### JavaScript Import API
54 When using the `.import(path)` method, these imports are deferred until evaluation:
56 var stylus = require('../')
57 , str = require('fs').readFileSync(__dirname + '/test.styl', 'utf8');
60 .set('filename', __dirname + '/test.styl')
61 .import('mixins/vendor')
62 .render(function(err, css){
67 The following are essentially equivalent:
69 @import 'mixins/vendor'
72 .import('mixins/vendor')