gitmyhub

stylus-loader

JavaScript ★ 3 updated 10y ago ⑂ fork

:art: A stylus loader for webpack.

A webpack plugin that compiles Stylus stylesheets into standard CSS as part of your build pipeline.

JavaScriptWebpackStyluscomplexity 2/5

Plain-English Explanation

Stylus-loader is a tool that lets you write stylesheets in a simpler language called Stylus and automatically convert them to regular CSS that browsers understand. Think of it as a translator: you write cleaner, shorter style rules in Stylus format, and the tool compiles them into standard CSS behind the scenes so your website can actually use them.

The tool works as a plugin for webpack, which is a bundler—a program that combines all your project files (JavaScript, CSS, images, etc.) into optimized packages for the web. When you have a .styl file (Stylus format) in your project, stylus-loader intercepts it, converts it to CSS, and feeds it into the rest of your build pipeline. You can then either extract just the compiled CSS, or use another tool called style-loader to automatically inject those styles directly into your web page when it loads.

You'd use this if you prefer Stylus's more concise syntax over writing plain CSS—for example, Stylus lets you skip brackets and semicolons, use variables and math operators, and organize imports cleanly. It's particularly handy if you're using design frameworks that ship in Stylus format, like Bootstrap Stylus, because the loader can find and import those files automatically from your node_modules folder. The README shows you can also extend Stylus with plugins (like nib, which adds shortcuts for common browser features) to get even more power.

One notable point: the tool doesn't ship with Stylus built in. You have to install Stylus separately in your project alongside the loader. This gives you flexibility to use whichever version you need, rather than being locked to what the loader author chose.

Where it fits