From 4917961736cb4d01da31183a90a0f33623684c72 Mon Sep 17 00:00:00 2001 From: tamaina Date: Sun, 29 May 2022 10:57:06 +0900 Subject: [PATCH] preload app css (#8752) --- packages/backend/src/config/load.ts | 2 +- packages/backend/src/server/web/index.ts | 4 +-- .../backend/src/server/web/views/base.pug | 32 ++++++++++++------- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/packages/backend/src/config/load.ts b/packages/backend/src/config/load.ts index c2e6bea45..9654a4f3b 100644 --- a/packages/backend/src/config/load.ts +++ b/packages/backend/src/config/load.ts @@ -46,7 +46,7 @@ export default function load() { mixin.authUrl = `${mixin.scheme}://${mixin.host}/auth`; mixin.driveUrl = `${mixin.scheme}://${mixin.host}/files`; mixin.userAgent = `Misskey/${meta.version} (${config.url})`; - mixin.clientEntry = clientManifest['src/init.ts'].file.replace(/^_client_dist_\//, ''); + mixin.clientEntry = clientManifest['src/init.ts']; if (!config.redis.prefix) config.redis.prefix = mixin.host; diff --git a/packages/backend/src/server/web/index.ts b/packages/backend/src/server/web/index.ts index 9e31f2389..0b2c62c04 100644 --- a/packages/backend/src/server/web/index.ts +++ b/packages/backend/src/server/web/index.ts @@ -74,9 +74,9 @@ app.use(views(_dirname + '/views', { extension: 'pug', options: { version: config.version, - clientEntry: () => process.env.NODE_ENV === 'production' ? + getClientEntry: () => process.env.NODE_ENV === 'production' ? config.clientEntry : - JSON.parse(readFileSync(`${_dirname}/../../../../../built/_client_dist_/manifest.json`, 'utf-8'))['src/init.ts'].file.replace(/^_client_dist_\//, ''), + JSON.parse(readFileSync(`${_dirname}/../../../../../built/_client_dist_/manifest.json`, 'utf-8'))['src/init.ts'], config, }, })); diff --git a/packages/backend/src/server/web/views/base.pug b/packages/backend/src/server/web/views/base.pug index a488e5117..69ddb73c0 100644 --- a/packages/backend/src/server/web/views/base.pug +++ b/packages/backend/src/server/web/views/base.pug @@ -1,17 +1,23 @@ block vars +block loadClientEntry + - const clientEntry = getClientEntry(); + doctype html -!= '\n' +// + - + + _____ _ _ + | |_|___ ___| |_ ___ _ _ + | | | | |_ -|_ -| \'_| -_| | | + |_|_|_|_|___|___|_,_|___|_ | + |___| + Thank you for using Misskey! + If you are reading this message... how about joining the development? + https://github.com/misskey-dev/misskey + + html @@ -30,9 +36,11 @@ html link(rel='prefetch' href='https://xn--931a.moe/assets/info.jpg') link(rel='prefetch' href='https://xn--931a.moe/assets/not-found.jpg') link(rel='prefetch' href='https://xn--931a.moe/assets/error.jpg') - link(rel='preload' href='/assets/fontawesome/css/all.css' as='style') link(rel='stylesheet' href='/assets/fontawesome/css/all.css') + each href in clientEntry.css + link(rel='preload' href=`/assets/${href}` as='style') + title block title = title || 'Misskey' @@ -52,7 +60,7 @@ html script. var VERSION = "#{version}"; - var CLIENT_ENTRY = "#{clientEntry()}"; + var CLIENT_ENTRY = "#{clientEntry.file}"; script include ../boot.js