UNPKG

sharyn

Version:

Combines all the other packages under one.

36 lines (27 loc) 2.36 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault"); var _serializeJavascript = _interopRequireDefault(require("serialize-javascript")); var _wdsUtil = require("@sharyn/webpack-config/wds-util"); var _env = require("@sharyn/env"); var _checkSetup = require("@sharyn/check-setup"); var _cleanCss = _interopRequireDefault(require("clean-css")); /* eslint-disable import/no-extraneous-dependencies */ // -disable-next-line // -disable-next-line // -disable-next-line var robotoLink = " <link rel=\"stylesheet\" href=\"https://fonts.googleapis.com/css?family=Roboto:300,400,500\" />"; var htmlBase = function htmlBase(_ref) { var windowVarPairs = _ref.windowVars, _ref$rootId = _ref.rootId, rootId = _ref$rootId === void 0 ? 'app' : _ref$rootId, _ref$appHtml = _ref.appHtml, appHtml = _ref$appHtml === void 0 ? '' : _ref$appHtml, css = _ref.css, helmet = _ref.helmet, swPath = _ref.swPath; var windowVarsScriptTags = windowVarPairs ? windowVarPairs.map(function (p) { return " <script>window.".concat(p[0], " = ").concat((0, _serializeJavascript.default)(p[1]), "</script>"); }).join("\n") : ''; return "<!doctype html>\n<html ".concat(!_env.NO_SSR && helmet ? helmet.htmlAttributes.toString() : '', ">\n <head>\n <meta charset=\"utf-8\">\n").concat(!_env.NO_SSR && helmet ? helmet.title.toString() : '', "\n").concat(!_env.NO_SSR && helmet ? helmet.meta.toString() : '', "\n").concat(!_env.NO_SSR && helmet ? helmet.link.toString() : '', "\n").concat((0, _checkSetup.hasPackage)('@material-ui/core') ? robotoLink : '', "\n").concat(!_env.NO_SSR && css ? " <style id=\"jss-ssr\">".concat(new _cleanCss.default().minify(css).styles, "</style>") : '', "\n </head>\n <body ").concat(!_env.NO_SSR && helmet ? helmet.bodyAttributes.toString() : '', ">\n <div id=\"").concat(rootId, "\">").concat(_env.NO_SSR ? '' : appHtml, "</div>\n").concat(swPath ? " <script>navigator.serviceWorker && window.addEventListener('load', () => navigator.serviceWorker.register('".concat(swPath, "'))</script>") : '', "\n").concat(_env.SSR_ONLY ? '' : windowVarsScriptTags, "\n").concat(_env.SSR_ONLY ? '' : " <script src=\"".concat(_wdsUtil.WDS_PATH, "/static/js/bundle.js\"></script>"), "\n </body>\n</html>"); }; module.exports = htmlBase;