Git Product home page Git Product logo

express-inline-css-amp's Introduction

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]

express-inline-css-amp's People

Contributors

eder avatar mateusbrigalante avatar

Stargazers

 avatar  avatar

express-inline-css-amp's Issues

Error when using require

Hi,
I am trying to use this repo, but I am getting an error when I try to require (not import) your lib:
in my app.js:

var inlineCSSAMP = require('express-inline-css-amp');

Error in my console:

module.js:457
    throw err;
    ^

Error: Cannot find module 'babel-runtime/helpers/classCallCheck'
    at Function.Module._resolveFilename (module.js:455:15)
    at Function.Module._load (module.js:403:25)
    at Module.require (module.js:483:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/***/Documents/dev/***/node_modules/express-inline-css-amp/lib/index.js:8:24)
    at Module._compile (module.js:556:32)
    at Object.Module._extensions..js (module.js:565:10)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)
    at Function.Module._load (module.js:424:3)

I generated this project using express generator.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.