# node-sass-endpoint

> Easily serve sassy css assets on express

Latest version **0.4.0** (published 2019-01-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install node-sass-endpoint
pnpm add node-sass-endpoint
yarn add node-sass-endpoint
bun add node-sass-endpoint
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.4.0 |
| Published | 2019-01-23 |
| First published | 2015-09-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 5.2 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Gilbert |
| Maintainers | mindeavor |

## Links

- npm: https://www.npmjs.com/package/node-sass-endpoint
- Repository: https://github.com/mindeavor/node-sass-endpoint
- Homepage: https://github.com/mindeavor/node-sass-endpoint#readme
- Issues: https://github.com/mindeavor/node-sass-endpoint/issues
- npm.io page: https://npm.io/package/node-sass-endpoint

## Dependencies (1)

- [node-sass](https://npm.io/package/node-sass.md) 4.x

## Recent versions

- 0.4.0 (latest) — 2019-01-23
- 0.3.2 — 2019-01-23
- 0.3.1 — 2016-03-08
- 0.3.0 — 2015-11-11
- 0.2.1 — 2015-10-03
- 0.2.0 — 2015-09-29
- 0.1.1 — 2015-09-28
- 0.1.0 — 2015-09-25

## README

# 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

- [node-sass](https://www.npmjs.com/package/node-sass) (taken care of by npm install)
- ES6 `Object.assign` (either use node v4.0+ or a [polyfill](https://www.npmjs.com/package/es6-object-assign))

### 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`:

```javascript
// server.js
var express = require('express');
var sass = require('node-sass-endpoint');
var app  = express();

// Serve CSS
app.get('/assets/app-bundle.css',
  sass.serve('./client/app.scss'));

// Serve HTML
var path = require('path')
app.get('/', function (req, res) {
  res.sendFile( path.resolve(__dirname, '../client/public/admin.html') )
})

console.log("Listening on port 5555...");
app.listen(5555);
```

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`:

```html
<html>
<head>
    <link rel="stylesheet" href="/assets/app-bundle.css">
</head>
<body>
    <!-- page content -->
</body>
</html>
```

## Advanced Usage

```javascript
app.get(
  '/assets/app-bundle.css',
  sass.serve('./client/app.scss', {

    // (dev only) defaults to parent folder of scss file.
    // Any sass file changes in this directory will clear the output cache.
    watchDir: './client/',

    // Defaults to parent folder of scss file.
    // The node_modules/ is always included.
    includePaths: ['./client/'],

    // Defaults to "nested". Can be one of: "nested", "expanded", "compact", or "compressed".
    outputStyle: 'compressed',

    // Defaults to false
    debug: false
  })
);
```

---
_Source: https://npm.io/package/node-sass-endpoint · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
