A middleware implementation of polymer-build which produces similar results to that of polymer serve
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);