0.2.5 • Published 4 years ago

express-stylus-middleware v0.2.5

Weekly downloads
5
License
MIT
Repository
github
Last release
4 years ago

Express Stylus middleware

Stylus-to-CSS conversion middleware for Express to make simple magic on the fly.
It's a Stylus-version of Express-less middleware

Installation

npm i express-stylus-middleware -S

Usage

const express = require("express");
const expressStylus = require("express-stylus-middleware");  
const app = express();  

app.use("/css", expressStylus(__dirname + "/stylus-css"));

Also you can use cache:

app.use("/css", expressStylus(__dirname + "/stylus-css"), { cache: true });

And make compressed css:

app.use("/css", expressStylus(__dirname + "/stylus-css", { compress: true }));

Additionally, you can use some Stylus's in-build options (in theory, not tested):

`force`     Always re-compile
`compile`   Custom compile function, accepting the arguments
              `(str, path)`.
`firebug`   Emits debug infos in the generated css that can
              be used by the FireStylus Firebug plugin
`linenos`   Emits comments in the generated css indicating 
              the corresponding stylus line
`sourcemap` Generates a sourcemap in sourcemaps v3 format

Autoprefixer

Even if you don't use task runners or bundlers, you can turn on PostCSS/Autoprefixer:

app.use("/css", expressStylus(__dirname + "/stylus-css", {
    autoprefixer: true
}));

By default browsers option is set to last 2 versions. You can modify it:

app.use("/css", expressStylus(__dirname + "/stylus-css", {
    autoprefixer: { browsers: ['Firefox > 20']}
}));

You can set all Autoprefixer options in the same way.

Usage with express.static

You have to use express-stylus-middleware before express.static

app.use('/css', expressStylus(__dirname + '/stylus-css'));
app.use(express.static('public'));

Testing

npm test

Licence

MIT

0.2.5

4 years ago

0.2.4

4 years ago

0.2.3

4 years ago

0.2.2

5 years ago

0.2.1

6 years ago

0.2.0

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago