Run prettier.

This commit is contained in:
Dillon Kearns 2020-04-13 15:12:16 -07:00
parent fb9d3e5ed6
commit b614a4cd26
2 changed files with 21 additions and 21 deletions

View File

@ -44,14 +44,14 @@ function start({ routes, debug, customPort, manifestConfig, routesWithRequests,
log: console.log, path: '/__webpack_hmr'
}))
app.use("*", function(req, res, next) {
app.use("*", function (req, res, next) {
// don't know why this works, but it does
// see: https://github.com/jantimon/html-webpack-plugin/issues/145#issuecomment-170554832
const filename = path.join(compiler.outputPath, "index.html");
const route = req.originalUrl.replace(/(\w)\/$/, "$1").replace(/^\//, "");
const isPage = routes.includes(route);
compiler.outputFileSystem.readFile(filename, function(err, result) {
compiler.outputFileSystem.readFile(filename, function (err, result) {
const contents = isPage
? replaceBaseAndLinks(result.toString(), route)
: result
@ -249,7 +249,7 @@ function webpackOptions(
// process.cwd prefixed node_modules above).
path.resolve(path.dirname(require.resolve('webpack')), '../../'),
],
],
extensions: [".js", ".elm", ".scss", ".png", ".html"]
},
module: {
@ -356,7 +356,7 @@ function webpackOptions(
entry: [
require.resolve("webpack-hot-middleware/client"),
"./index.js",
],
],
plugins: [
new webpack.NamedModulesPlugin(),
// Prevents compilation errors causing the hot loader to lose state
@ -395,10 +395,10 @@ function pathToRoot(cleanedRoute) {
return cleanedRoute === ""
? cleanedRoute
: cleanedRoute
.split("/")
.map(_ => "..")
.join("/")
.replace(/\.$/, "./")
.split("/")
.map(_ => "..")
.join("/")
.replace(/\.$/, "./")
}

View File

@ -11,9 +11,9 @@ module.exports = function pagesInit(
prefetchedPages = [window.location.pathname];
initialLocationHash = document.location.hash.replace(/^#/, "");
return new Promise(function(resolve, reject) {
return new Promise(function (resolve, reject) {
document.addEventListener("DOMContentLoaded", _ => {
new MutationObserver(function() {
new MutationObserver(function () {
elmViewRendered = true;
if (headTagsAdded) {
document.dispatchEvent(new Event("prerender-trigger"));
@ -32,7 +32,7 @@ function loadContentAndInitializeApp(/** @type { init: any } */ mainElmModule)
const isPrerendering = navigator.userAgent.indexOf("Headless") >= 0
const path = window.location.pathname.replace(/(\w)$/, "$1/")
return httpGet(`${window.location.origin}${path}content.json`).then(function(/** @type JSON */ contentJson) {
return httpGet(`${window.location.origin}${path}content.json`).then(function (/** @type JSON */ contentJson) {
const app = mainElmModule.init({
flags: {
@ -62,10 +62,10 @@ function loadContentAndInitializeApp(/** @type { init: any } */ mainElmModule)
fromElm.head.forEach(headTag => {
appendTag(headTag);
});
headTagsAdded = true;
if (elmViewRendered) {
document.dispatchEvent(new Event("prerender-trigger"));
}
headTagsAdded = true;
if (elmViewRendered) {
document.dispatchEvent(new Event("prerender-trigger"));
}
} else {
setupLinkPrefetching();
}
@ -73,7 +73,7 @@ function loadContentAndInitializeApp(/** @type { init: any } */ mainElmModule)
if (module.hot) {
module.hot.addStatusHandler(function(status) {
module.hot.addStatusHandler(function (status) {
if (status === 'idle') {
console.log('Reloaded!!!!!!!!!!', status)
app.ports.fromJsPort.send({});
@ -142,7 +142,7 @@ function setupLinkPrefetchingHelp(
const links = document.querySelectorAll("a");
links.forEach(link => {
// console.log(link.pathname);
link.addEventListener("mouseenter", function(event) {
link.addEventListener("mouseenter", function (event) {
if (
event &&
event.target &&
@ -186,11 +186,11 @@ function appendTag(/** @type {HeadTag} */ tagDetails) {
}
function httpGet(/** @type string */ theUrl) {
return new Promise(function(resolve, reject) {
return new Promise(function (resolve, reject) {
const xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
resolve(JSON.parse(xmlHttp.responseText));
xmlHttp.onreadystatechange = function () {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
resolve(JSON.parse(xmlHttp.responseText));
}
xmlHttp.onerror = reject;
xmlHttp.open("GET", theUrl, true); // true for asynchronous