UNPKG

2.16 kBJavaScriptView Raw
1"use strict";
2
3var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
4
5var _serializeJavascript = _interopRequireDefault(require("serialize-javascript"));
6
7var _wdsUtil = require("@sharyn/webpack-config/wds-util");
8
9var _env = require("@sharyn/env");
10
11var _checkSetup = require("@sharyn/check-setup");
12
13var _cleanCss = _interopRequireDefault(require("clean-css"));
14
15/* eslint-disable import/no-extraneous-dependencies */
16// -disable-next-line
17// -disable-next-line
18// -disable-next-line
19var robotoLink = " <link rel=\"stylesheet\" href=\"https://fonts.googleapis.com/css?family=Roboto:300,400,500\" />";
20
21var htmlBase = function htmlBase(_ref) {
22 var windowVarPairs = _ref.windowVars,
23 _ref$rootId = _ref.rootId,
24 rootId = _ref$rootId === void 0 ? 'app' : _ref$rootId,
25 _ref$appHtml = _ref.appHtml,
26 appHtml = _ref$appHtml === void 0 ? '' : _ref$appHtml,
27 css = _ref.css,
28 helmet = _ref.helmet;
29 var windowVarsScriptTags = windowVarPairs ? windowVarPairs.map(function (p) {
30 return " <script>window.".concat(p[0], " = ").concat((0, _serializeJavascript.default)(p[1]), "</script>");
31 }).join("\n") : '';
32 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(_env.SSR_ONLY ? '' : windowVarsScriptTags, "\n").concat(_env.SSR_ONLY ? '' : " <script src=\"".concat(_wdsUtil.WDS_PATH, "/static/js/bundle.js\"></script>"), "\n </body>\n</html>");
33};
34
35module.exports = htmlBase;
\No newline at end of file