# express-slick-css

> An express middleware which cleans all the unused css in the template and makes the css slick

Latest version **1.0.0** (published 2018-08-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install express-slick-css
pnpm add express-slick-css
yarn add express-slick-css
bun add express-slick-css
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2018-08-13 |
| First published | 2018-08-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 28.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | ameerthehacker |
| Maintainers | ameerthehacker |
| Keywords | css, express, clean-css |

## Links

- npm: https://www.npmjs.com/package/express-slick-css
- Repository: https://github.com/ameerthehacker/express-slick-css
- Homepage: https://github.com/ameerthehacker/express-slick-css#readme
- Issues: https://github.com/ameerthehacker/express-slick-css/issues
- npm.io page: https://npm.io/package/express-slick-css

## Dependencies (4)

- [chalk](https://npm.io/package/chalk.md) ^2.4.1
- [jsdom](https://npm.io/package/jsdom.md) ^11.12.0
- [uncss](https://npm.io/package/uncss.md) ^0.16.2
- [bluebird](https://npm.io/package/bluebird.md) ^3.5.1

## Alternatives

- [style-dictionary](https://npm.io/package/style-dictionary.md) — 2.0M weekly downloads
- [postcss-merge-idents](https://npm.io/package/postcss-merge-idents.md) — 1.7M weekly downloads
- [@fontsource/noto-sans](https://npm.io/package/@fontsource/noto-sans.md) — 93.0K weekly downloads
- [uglifycss](https://npm.io/package/uglifycss.md) — 71.6K weekly downloads
- [mat4-interpolate](https://npm.io/package/mat4-interpolate.md) — 23.3K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2018-08-13

## README

# Slick CSS :balloon:

[![CircleCI](https://circleci.com/gh/ameerthehacker/express-slick-css/tree/master.svg?style=svg)](https://circleci.com/gh/ameerthehacker/express-slick-css/tree/master)
[![codecov](https://codecov.io/gh/ameerthehacker/express-slick-css/branch/master/graph/badge.svg)](https://codecov.io/gh/ameerthehacker/express-slick-css)
[![tested with jest](https://img.shields.io/badge/tested_with-jest-99424f.svg)](https://github.com/facebook/jest)

No more bloated CSS styles :poop: in your websites.

## How it works?

1. It intercepts the **res.render** method in the express framework
2. Strips out all the stylesheets from the html document
3. Extracts only used styles using [uncss]
4. Creates a new stylesheet in the path specified(cssPath) and caches it
5. Adds the newly created stylesheet to the html document
6. Send the response

## How to use it?

1. Install the package

```bash
npm install express-slick-css --save
```

2. Add all the stylesheets to the layout

```html
...
<!-- rel='stylesheet' must be there otherwise it won't be picked up -->
<link href='/stylesheets/style.css' rel='stylesheet'>
...
```

3. Add the middleware before all the routes

```javascript
const slickify = require('express-slick-csss');
...
app.use(slickify(options));
...
app.use('/', indexRoutes);
```

## Options

|   Options    |                          Description                          | Mandatory | Default Value |
| :----------: | :-----------------------------------------------------------: | :-------: | :-----------: |
|  outputPath  |            path to save the new slick stylesheets             |    Yes    |      N/A      |
|   cssPath    |      path to look for stylesheets specified in link tag       |    No     |  outputPath   |
|  publicPath  | public path for serving css asset `eg. href="/css/style.css"` |    No     |      '/'      |
| uncssOptions |         Supports all the options provided by [uncss]          |    No     | Refer [uncss] |

## Example

```javascript
app.use(
  slickify({
    cssPath: path.join(__dirname, 'css'),
    // outputPath must exists
    // Add the outputPath to .gitignore if you want
    outputPath: path.join(__dirname, 'slick-css'),
    publicPath: '/stylesheets/',
    uncssOptions: {
      // Include global CSS frameworks here to keep it clean
      stylesheets  : ['lib/bootstrap/dist/css/bootstrap.css']
    }
  });
);
```

## How to contribute?

Feel free to create an issue for a feature request, bug and you can take up any of those to make a pull request

Show your support by :star: the repo

## License

MIT © [Ameer Jhan](mailto:ameerjhanprof@gmail.com)

[uncss]: https://github.com/uncss/uncss

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