This commit is contained in:
tamaina 2022-04-27 07:11:14 +00:00
parent c32cde5a4a
commit b6109b229d
2 changed files with 16 additions and 3 deletions

View file

@ -4,6 +4,7 @@
import { dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
import { PathOrFileDescriptor, readFileSync } from 'node:fs';
import ms from 'ms';
import Koa from 'koa';
import Router from '@koa/router';
@ -74,6 +75,11 @@ app.use(views(_dirname + '/views', {
options: {
version: config.version,
config,
...(process.env.NODE_ENV !== 'production' ? {
process,
_dirname,
readFileSync: (path: PathOrFileDescriptor): string => readFileSync(path, 'utf8'),
} : {}),
},
}));

View file

@ -50,9 +50,16 @@ html
style
include ../style.css
script.
var VERSION = "#{version}";
var CLIENT_ENTRY = "#{config.clientEntry}";
if process.env.NODE_ENV === 'production'
script.
var VERSION = "#{version}";
var CLIENT_ENTRY = "#{config.clientEntry}";
else
-
const clientEntry = JSON.parse(readFileSync(`${_dirname}/../../../../../built/_client_dist_/manifest.json`, 'utf-8'))['src/init.ts'].file.replace(/^_client_dist_\//, '');
script.
var VERSION = "#{version}";
var CLIENT_ENTRY = "#{clientEntry}";
script
include ../boot.js