@jrg/koa-sass v0.0.5
koa-dart-sass
Koa Sass Middleware using Dart Sass instead of Node-Sass
Example
The basic example is...
Install dependencies
npm install --save koa-mount koa koa-static @jrg/koa-sass
Make the style directory
mkdir styles
Create a simple SCSS
vi ./styles/test.scss
and add the following...$base-color: red; h1{ background-color:$base-color; }
Create the following class in a server.mjs
import mount from 'koa-mount'; import Koa from 'koa'; import serve from 'koa-static'; import {KoaSass} from '@jrg/koa-sass';
const app = new Koa(); const main = new Main(); const stylesApp = new Koa(); const sass = new KoaSass();
stylesApp.use(sass.koaMiddleware); stylesApp.use(serve('styles'));
app.use(mount('/styles', stylesApp)) app.listen(3000);
Run the application using
node --experimental-modules server.mjs
Visit http://locahost:3000/styles/test.scss. It should be rendered like a normal css file and can be used like...
link(rel="stylesheet" type="text/css" href="/styles/test.scss")
Issues
- Still working on an implementation to allow sass files
- Add ability to fallback to node-sass
- Add additional configuration params