express-inline-css-amp

3.0.2 • Public • Published

express-inline-css-amp

CircleCI

⚡️ Express middleware to generate inline rendering CSS for AMP:

<!doctype html>
<html ⚡>
  <head>
    <title>Exemple</title>
  </head>
</html>

Generated

<!doctype html>
<html ⚡>
  <head>
    <title>Exemple</title>
    <style amp-custom>
      ...
    </style>
  </head>
</html>

Installation

  npm install --save express-inline-css-amp

Preview

// The render method
import path from 'path';
import express from 'express';
import inlineCSSAMP from 'express-inline-css-amp';
 
const app = express();
// Yes its works with css, scss and sass \o/
app.use(inlineCSSAMP({
  CSSPathBase: path.join(__dirname,'../public/assets/css/'),
  CSSFilePath: path.join(__dirname,'../public/assets/css/style.scss'),
  version: new Date().getTime(),
}));
 
app.get('/', (req, res) => {
  res.render('index', {});
});
 
  • Yes its works with css, scss and sass \o/ and load css by view eg. the view home load home.css if one exists.

  • CSSPathBase: This path is set as /tmp/ by default used to load css compiled;

  • CSSFilePath: Path of the final css file where rules are taken out.

  • CCSMinify: Default is true, this brings up the possibility of mifying the css file.

  • version: value - Now, we can cache from css generated automatically just in production

License

MIT © [Eder Eduardo]

Dependents (0)

Package Sidebar

Install

npm i express-inline-css-amp

Weekly Downloads

4

Version

3.0.2

License

MIT

Unpacked Size

20.6 kB

Total Files

13

Last publish

Collaborators

  • edereduardo