node-sass-endpoint
Easily serve a SASS file as CSS from an express endpoint. No grunt/gulp, no build files, no required configuration – just pure data.
Dependencies
Installation
$ npm install node-sass-endpoint --save
Usage - Easy Version
Assuming you have the following directory structure:
client/
├── app.scss
└── index.html
server/
└── index.js
package.json
Then you can write the following as your server/index.js
:
// server.jsvar express = ;var sass = ;var app = ; // Serve CSSapp; // Serve HTMLvar path = app console;app;
And run node server/index.js
.
Now any GET request to localhost:5555/assets/app-bundle.css
will compile and serve the SASS file located at ./client/app.scss
. Any @import
statements within app.scss
will also be included in the final output.
With that said, here is an example of using your sass-compiled CSS in client/index.html
:
<!-- page content -->
Advanced Usage
app;