Skip to content

ztzven/connect-polymer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Connect Polymer

A middleware implementation of polymer-build which produces similar results to that of polymer serve

Example implementation

const path = require("path");
const polymer = require("connect-polymer");
const polymerOptions = {
    root: path.join(__dirname, "."), // Path to your polymer app (or component) folder
    npm: true,
    ignoreBasePath: false
};

const app = require("express")();

// Middleware for Modules
app.use("*", polymer.middleware(polymerOptions));
// Fall through to serving index.html on 404
app.use("*", async function(req, res, next) {
    const userAgent = req.get("user-agent");
    const content = await polymer.transformFile(userAgent, path.join(__dirname, "index.html"), polymerOptions);
    res.type(".html");
    return res.send(content);
});

app.listen(80);

About

A middleware implementation of polymer build

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published