项目作者: jlopezxs

项目描述 :
:mag: Express middleware to generate inline critical rendering CSS
高级语言: JavaScript
项目地址: git://github.com/jlopezxs/express-inline-css.git
创建时间: 2016-08-30T06:58:59Z
项目社区:https://github.com/jlopezxs/express-inline-css

开源协议:MIT License

下载


express-inline-css

:zap: Express middleware to generate inline critical rendering CSS to improve render performance

Build Status
Dependencies Status
Styled with Prettier
Commitizen friendly
Greenkeeper badge

Installation

  1. npm install --save express-inline-css

Preview

  1. // Overriding the render method
  2. import express from 'express';
  3. import inlineCSS from 'express-inline-css';
  4. const app = express();
  5. app.use(inlineCSS({
  6. override: true,
  7. cssFilePath: '../client/public/css/style.css'
  8. }));
  9. app.get('/', (req, res) => {
  10. res.render('index', {});
  11. });
  1. // Using renderInlineCSS method
  2. import express from 'express';
  3. import inlineCSS from 'express-inline-css';
  4. const app = express();
  5. app.use(inlineCSS({
  6. override: false,
  7. cssFilePath: '../client/public/css/style.css'
  8. }));
  9. app.get('/', (req, res) => {
  10. res.renderInlineCSS('index', {});
  11. });

Usage

inlineCSS({ cssFilePath, [override] });

where:

  • cssFilePath: Path of the final css file where rules are taken out.
  • override (optional): It brings you the possibility to override the method render or use renderInlineCSS method.

License

MIT © Jordi López