Express middleware to generate inline rendering CSS for AMP
⚡ Express middleware to generate inline rendering CSS for AMP:
<!doctype html>
<html ⚡>
<head>
<title>Exemple</title>
</head>
</html>
<!doctype html>
<html ⚡>
<head>
<title>Exemple</title>
<style amp-custom>
...
</style>
</head>
</html>
npm install --save express-inline-css-amp
// 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
MIT © [Eder Eduardo]