How to use stylus

Comprehensive stylus code examples:

How to use stylus.Compiler:

463
464
465
466
467
468
469
470
471
472
473
  };
}


function urlResolver(options = {}) {
  function resolver(url) {
    const compiler = new _stylus.Compiler(url);
    const {
      filename
    } = url;
    compiler.isURL = true;

How to use stylus.Parser:

160
161
162
163
164
165
166
167
168
169

const newOptions = (0, _full.klona)({ ...options,
  filename,
  cache: false
});
const parser = new _stylus.Parser(code, newOptions);
let ast;

try {
  ast = parser.parse();

How to use stylus.Evaluator:

182
183
184
185
186
187
188
189
190
191
if (firstNode.name === "url") {
  return;
}

if (!firstNode.val) {
  const evaluator = new _stylus.Evaluator(ast);
  firstNode = evaluator.visit.call(evaluator, firstNode).first;
}

const originalNodePath = !firstNode.val.isNull && firstNode.val || firstNode.name;

How to use stylus.utils:

204
205
206
207
208
209
210
211
212
  nodePath += ".styl";
}

const isGlob = _fastGlob.default.isDynamicPattern(nodePath);

found = _stylus.utils.find(nodePath, this.paths, this.filename);

if (found && isGlob) {
  const [globTask] = _fastGlob.default.generateTasks(nodePath);

How to use stylus.nodes:

472
473
474
475
476
477
478
479
480
481
compiler.isURL = true;
const visitedUrl = url.nodes.map(node => compiler.visit(node)).join("");
const splitted = visitedUrl.split("!");
const parsedUrl = (0, _url.parse)(splitted.pop()); // Parse literal

const literal = new _stylus.nodes.Literal(`url("${parsedUrl.href}")`);
let {
  pathname
} = parsedUrl;
let {